-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi18n.ts
More file actions
90 lines (79 loc) · 2.86 KB
/
i18n.ts
File metadata and controls
90 lines (79 loc) · 2.86 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import en from './locales/en.json';
import ro from './locales/ro.json';
export enum TranslationKey {
DASHBOARD = "dashboard",
PROFILE_MENU = "profileMenu",
LOGIN_PAGE = "loginPage",
REGISTER_PAGE = "registerPage",
FILES_PAGE = "filesPage",
AI_CHAT = "aiChat",
ERRORS = "errors",
SUCCESS = "success",
}
export const translations = {
dashboard: {
profile: `${TranslationKey.DASHBOARD}.profile`,
settings: `${TranslationKey.DASHBOARD}.settings`,
home: `${TranslationKey.DASHBOARD}.home`,
pdf: `${TranslationKey.DASHBOARD}.PDF`,
},
profileMenu: {
profile: `${TranslationKey.PROFILE_MENU}.profile`,
settings: `${TranslationKey.PROFILE_MENU}.settings`,
logout: `${TranslationKey.PROFILE_MENU}.logout`,
ro: `${TranslationKey.PROFILE_MENU}.ro`,
en: `${TranslationKey.PROFILE_MENU}.en`,
},
loginPage: {
login: `${TranslationKey.LOGIN_PAGE}.login`,
account: `${TranslationKey.LOGIN_PAGE}.account`,
password: `${TranslationKey.LOGIN_PAGE}.password`,
rememberMe: `${TranslationKey.LOGIN_PAGE}.rememberMe`,
registerNewAccount: `${TranslationKey.LOGIN_PAGE}.registerNewAccount`,
},
registerPage: {
register: `${TranslationKey.REGISTER_PAGE}.register`,
username: `${TranslationKey.REGISTER_PAGE}.username`,
email: `${TranslationKey.REGISTER_PAGE}.email`,
password: `${TranslationKey.REGISTER_PAGE}.password`,
confirmPassword: `${TranslationKey.REGISTER_PAGE}.confirmPassword`,
alreadyHaveAccount: `${TranslationKey.REGISTER_PAGE}.aldreadyHaveAccount`,
},
filesPage: {
downloadFile: `${TranslationKey.FILES_PAGE}.downloadFile`,
},
aiChat: {
thinking: `${TranslationKey.AI_CHAT}.thinking`,
thinkingTime: `${TranslationKey.AI_CHAT}.thinkingTime`
},
errors: {
isRequired: `${TranslationKey.ERRORS}.isRequired`,
invalidEmail: `${TranslationKey.ERRORS}.invalidEmail`,
passwordsDoNotMatch: `${TranslationKey.ERRORS}.passwordsDoNotMatch`,
userNotFound: `${TranslationKey.ERRORS}.user_not_found`,
},
success: {
accountCreated: `${TranslationKey.SUCCESS}.accountCreated`,
},
} as const;
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
en: { translation: en },
ro: { translation: ro },
},
fallbackLng: 'en',
interpolation: { escapeValue: false },
detection: {
// order in which detection is done
order: ['localStorage', 'navigator'],
// where to store the language
caches: ['localStorage'],
},
});
export default i18n;