2023-02-13 20:20:08 +03:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2023-02-13 20:20:08 +03:30
|
|
|
|
|
|
|
|
import { use } from 'i18next';
|
|
|
|
|
import { initReactI18next } from 'react-i18next';
|
|
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
2024-04-14 17:32:25 +02:00
|
|
|
import HttpBackend from 'i18next-http-backend';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Keys have to match {@link ISOLanguages} codes, they're used for showing the language name in the dropdown in the {@link Settings}.<br/>
|
|
|
|
|
* In case there is no language code for the key in {@link ISOLanguages}, the corresponding language has to be added
|
2024-05-11 01:28:25 +02:00
|
|
|
*
|
|
|
|
|
* **IMPORTANT:**
|
|
|
|
|
*
|
|
|
|
|
* This is generated by the `i18n:gen-resources` script
|
2024-04-14 17:32:25 +02:00
|
|
|
*/
|
|
|
|
|
export const i18nResources = [
|
|
|
|
|
'ar',
|
2024-05-11 01:28:25 +02:00
|
|
|
'bn',
|
2024-11-27 22:02:26 +01:00
|
|
|
'da',
|
2024-04-14 17:32:25 +02:00
|
|
|
'de',
|
|
|
|
|
'en',
|
|
|
|
|
'es',
|
|
|
|
|
'fr',
|
|
|
|
|
'id',
|
|
|
|
|
'it',
|
|
|
|
|
'ja',
|
|
|
|
|
'ko',
|
2024-04-24 23:53:43 +02:00
|
|
|
'nb-NO',
|
2024-08-05 16:06:54 +02:00
|
|
|
'nl',
|
2024-04-14 17:32:25 +02:00
|
|
|
'pt',
|
2024-05-11 01:28:25 +02:00
|
|
|
'ru',
|
2024-04-14 17:32:25 +02:00
|
|
|
'sv',
|
2024-07-17 22:54:26 +02:00
|
|
|
'th',
|
2024-04-24 23:53:43 +02:00
|
|
|
'tr',
|
2024-04-14 17:32:25 +02:00
|
|
|
'uk',
|
|
|
|
|
'vi',
|
|
|
|
|
'zh_Hans',
|
|
|
|
|
'zh_Hant',
|
2024-04-24 23:56:06 +02:00
|
|
|
] as const;
|
|
|
|
|
|
|
|
|
|
export type I18nResourceCode = (typeof i18nResources)[number];
|
2023-02-13 20:20:08 +03:30
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const i18n = use(initReactI18next)
|
2024-04-14 17:32:25 +02:00
|
|
|
.use(HttpBackend)
|
2023-02-13 20:20:08 +03:30
|
|
|
.use(LanguageDetector)
|
|
|
|
|
.init({
|
|
|
|
|
fallbackLng: 'en',
|
2024-04-14 17:32:25 +02:00
|
|
|
|
|
|
|
|
backend: {
|
|
|
|
|
loadPath: '/locales/{{lng}}.json',
|
|
|
|
|
allowMultiLoading: true,
|
|
|
|
|
},
|
|
|
|
|
|
2023-02-13 20:20:08 +03:30
|
|
|
interpolation: {
|
|
|
|
|
escapeValue: false,
|
2023-11-12 01:41:10 +01:00
|
|
|
format: (value, format) => {
|
|
|
|
|
switch (format) {
|
|
|
|
|
case 'lowercase':
|
2023-11-27 19:14:58 +01:00
|
|
|
return value.toLocaleLowerCase();
|
2023-11-12 01:41:10 +01:00
|
|
|
default:
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-02-13 20:20:08 +03:30
|
|
|
},
|
2024-04-14 17:32:25 +02:00
|
|
|
|
2023-02-14 16:28:37 +03:30
|
|
|
returnNull: false,
|
|
|
|
|
debug: process.env.NODE_ENV !== 'production',
|
2023-02-13 20:20:08 +03:30
|
|
|
});
|