mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Centralize Lang
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user