-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintlayer.config.ts
More file actions
50 lines (43 loc) · 1.36 KB
/
intlayer.config.ts
File metadata and controls
50 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Locales, type IntlayerConfig } from 'intlayer';
// Function to get the default locale from localStorage or browser
const getDefaultLocale = () => {
if (typeof window !== 'undefined') {
// Check localStorage first
const savedLanguage = localStorage.getItem('worknow-language');
if (savedLanguage) {
return savedLanguage as any;
}
// Auto-detect browser language
const browserLang = navigator.language || navigator.languages[0];
let detectedLang = 'ru'; // Default fallback
// Map browser language codes to our supported languages
if (browserLang.startsWith('en')) {
detectedLang = 'en';
} else if (browserLang.startsWith('he') || browserLang.startsWith('iw')) {
detectedLang = 'he';
} else if (browserLang.startsWith('ar')) {
detectedLang = 'ar';
} else if (browserLang.startsWith('uk') || browserLang.startsWith('ua')) {
detectedLang = 'uk';
} else if (browserLang.startsWith('ru')) {
detectedLang = 'ru';
}
return detectedLang as any;
}
return Locales.RUSSIAN; // Server-side fallback
};
const config: IntlayerConfig = {
internationalization: {
locales: [
Locales.RUSSIAN,
Locales.ENGLISH,
Locales.HEBREW,
Locales.ARABIC,
Locales.UKRAINIAN,
],
defaultLocale: getDefaultLocale(),
// Use strict mode to ensure all locales are properly implemented
strictMode: 'inclusive',
},
};
export default config;