2020-03-19 15:37:38 +00:00
import i18n from 'i18next' ;
import { initReactI18next } from 'react-i18next' ;
2020-05-02 14:10:03 +00:00
const Backend = window . require ( 'i18next-fs-backend' ) ;
2020-03-19 15:37:38 +00:00
2022-11-22 15:23:41 +00:00
const remote = window . require ( '@electron/remote' ) ;
const { commonI18nOptions , fallbackLng , loadPath , addPath } = remote . require ( './i18n-common' ) ;
2020-03-19 15:37:38 +00:00
2021-03-28 17:12:58 +00:00
export { fallbackLng } ;
2020-05-02 15:27:46 +00:00
2020-03-19 15:37:38 +00:00
// https://github.com/i18next/i18next/issues/869
i18n
. use ( Backend )
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
2021-08-23 11:09:48 +00:00
// LanguageDetector is disabled because many users are used to english, and I cannot guarantee the status of all the translations so it's best to default to engligh https://github.com/mifi/lossless-cut/issues/346
2020-05-06 06:27:53 +00:00
// .use(LanguageDetector)
2020-03-19 15:37:38 +00:00
// pass the i18n instance to react-i18next.
. use ( initReactI18next )
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
2020-05-02 14:10:03 +00:00
// See also i18next-scanner.config.js
2020-03-19 15:37:38 +00:00
. init ( {
2021-03-28 17:12:58 +00:00
... commonI18nOptions ,
2020-03-19 15:37:38 +00:00
backend : {
2021-03-28 17:12:58 +00:00
loadPath ,
addPath ,
2020-03-19 15:37:38 +00:00
} ,
interpolation : {
escapeValue : false , // not needed for react as it escapes by default
} ,
} ) ;
export default i18n ;