Centralize Lang

This commit is contained in:
Enrico Ros
2024-04-06 14:27:21 -07:00
parent b70060d46e
commit 698c31943e
3 changed files with 10 additions and 3 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import type { ContentScaling } from '~/common/app.theme';
import { browserLangOrUS } from '~/common/util/pwaUtils';
// UI Preferences
@@ -54,7 +55,7 @@ export const useUIPreferencesStore = create<UIPreferencesStore>()(
// UI Features
preferredLanguage: (typeof navigator !== 'undefined') && navigator.language || 'en-US',
preferredLanguage: browserLangOrUS,
setPreferredLanguage: (preferredLanguage: string) => set({ preferredLanguage }),
centerMode: 'wide',
+5
View File
@@ -10,6 +10,11 @@ export const isMacUser = /Macintosh|MacIntel|MacPPC|Mac68K|iPad/.test(safeUA);
export const isChromeDesktop = safeUA.includes('Chrome') && !safeUA.includes('Mobile');
export const isFirefox = safeUA.includes('Firefox');
// frontend language
const browserLang = isBrowser ? window.navigator.language : '';
export const browserLangOrUS = browserLang || 'en-US';
export const browserLangNotUS = browserLangOrUS !== 'en-US';
// deployment environment
export const isVercelFromBackendOrSSR = !!process.env.VERCEL_ENV;
export const isVercelFromFrontend = !!process.env.NEXT_PUBLIC_VERCEL_URL;
+3 -2
View File
@@ -1,5 +1,7 @@
import { DLLMId, getKnowledgeMapCutoff } from '~/modules/llms/store-llms';
import { browserLangOrUS } from '~/common/util/pwaUtils';
/*type Variables =
| '{{Today}}'
| '{{Cutoff}}'
@@ -48,10 +50,9 @@ export function bareBonesPromptMixer(_template: string, assistantLlmId: DLLMId |
// {{LocaleNow}} - enough information to get on the same page with the user
if (mixed.includes('{{LocaleNow}}')) {
const userLocale = navigator.language || 'en-US';
// const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
// Format the current date and time according to the user's locale and timezone
const formatter = new Intl.DateTimeFormat(userLocale, {
const formatter = new Intl.DateTimeFormat(browserLangOrUS, {
weekday: 'short', // Full name of the day of the week
year: 'numeric', // Numeric year
month: 'short', // Full name of the month