ref: Convert i18n to TS (#11934)

This commit is contained in:
Robert Pintilii 2022-08-01 10:14:54 +03:00 committed by GitHub
parent 8e0cb583af
commit a6f93db8e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 26 deletions

View File

@ -1,5 +1,3 @@
// @flow
import i18next from 'i18next'; import i18next from 'i18next';
/** /**
@ -212,7 +210,7 @@ const _LANGUAGES = {
// Register all builtin languages with the i18n library. // Register all builtin languages with the i18n library.
for (const name in _LANGUAGES) { // eslint-disable-line guard-for-in for (const name in _LANGUAGES) { // eslint-disable-line guard-for-in
const { languages, main } = _LANGUAGES[name]; const { languages, main } = _LANGUAGES[name as keyof typeof _LANGUAGES];
i18next.addResourceBundle( i18next.addResourceBundle(
name, name,

View File

@ -1,6 +1,6 @@
/* @flow */
declare var config: Object; // eslint-disable-next-line no-var
declare var config: any;
/** /**
* Custom language detection, just returns the config property if any. * Custom language detection, just returns the config property if any.

View File

@ -1,6 +1,6 @@
/* @flow */
declare var navigator: Object; // eslint-disable-next-line no-var
declare var navigator: any;
/** /**
* Custom language detection, just returns the config property if any. * Custom language detection, just returns the config property if any.
@ -57,7 +57,7 @@ export default {
* @param {string} language - Language. * @param {string} language - Language.
* @returns {string} The normalized language. * @returns {string} The normalized language.
*/ */
function normalizeLanguage(language) { function normalizeLanguage(language: string) {
const [ lang, variant ] = language.replace('_', '-').split('-'); const [ lang, variant ] = language.replace('_', '-').split('-');
if (!variant || lang === variant) { if (!variant || lang === variant) {

View File

@ -1,5 +1,3 @@
// @flow
import moment from 'moment'; import moment from 'moment';
import i18next from './i18next'; import i18next from './i18next';
@ -94,10 +92,13 @@ export function getLocalizedDurationFormatter(duration: number) {
// showing the hour and we want to include the hour if the conference is // showing the hour and we want to include the hour if the conference is
// more than an hour long // more than an hour long
// @ts-ignore
if (moment.duration(duration).format('h') !== '0') { if (moment.duration(duration).format('h') !== '0') {
// @ts-ignore
return moment.duration(duration).format('h:mm:ss'); return moment.duration(duration).format('h:mm:ss');
} }
// @ts-ignore
return moment.duration(duration).format('mm:ss', { trim: false }); return moment.duration(duration).format('mm:ss', { trim: false });
} }

View File

@ -1,5 +1,3 @@
// @flow
import React from 'react'; import React from 'react';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';

View File

@ -1,6 +1,5 @@
// @flow // eslint-disable-next-line no-var
declare var APP: any;
declare var APP: Object;
import COUNTRIES_RESOURCES from 'i18n-iso-countries/langs/en.json'; import COUNTRIES_RESOURCES from 'i18n-iso-countries/langs/en.json';
import i18next from 'i18next'; import i18next from 'i18next';
@ -11,6 +10,8 @@ import LANGUAGES_RESOURCES from '../../../../lang/languages.json';
import MAIN_RESOURCES from '../../../../lang/main.json'; import MAIN_RESOURCES from '../../../../lang/main.json';
import { I18NEXT_INITIALIZED, LANGUAGE_CHANGED } from './actionTypes'; import { I18NEXT_INITIALIZED, LANGUAGE_CHANGED } from './actionTypes';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import languageDetector from './languageDetector'; import languageDetector from './languageDetector';
/** /**
@ -76,7 +77,7 @@ const options = {
i18next i18next
.use(navigator.product === 'ReactNative' ? {} : I18nextXHRBackend) .use(navigator.product === 'ReactNative' ? {} : I18nextXHRBackend)
.use(languageDetector) .use(languageDetector) // @ts-ignore
.init(options); .init(options);
// Add default language which is preloaded from the source code. // Add default language which is preloaded from the source code.

View File

@ -1,5 +1,3 @@
// @flow
import { NativeModules } from 'react-native'; import { NativeModules } from 'react-native';
import LANGUAGES_RESOURCES from '../../../../lang/languages.json'; import LANGUAGES_RESOURCES from '../../../../lang/languages.json';

View File

@ -1,12 +1,10 @@
/* @flow */
import BrowserLanguageDetector from 'i18next-browser-languagedetector'; import BrowserLanguageDetector from 'i18next-browser-languagedetector';
import configLanguageDetector from './configLanguageDetector'; import configLanguageDetector from './configLanguageDetector';
import customNavigatorDetector from './customNavigatorDetector'; import customNavigatorDetector from './customNavigatorDetector';
// eslint-disable-next-line no-var
declare var interfaceConfig: Object; declare var interfaceConfig: any;
/** /**
* The ordered list (by name) of language detectors to be utilized as backends * The ordered list (by name) of language detectors to be utilized as backends
@ -41,7 +39,10 @@ const languageDetector
// Add the language detector which looks the language up in the config. Its // Add the language detector which looks the language up in the config. Its
// order has already been established above. // order has already been established above.
// @ts-ignore
languageDetector.addDetector(customNavigatorDetector); languageDetector.addDetector(customNavigatorDetector);
// @ts-ignore
languageDetector.addDetector(configLanguageDetector); languageDetector.addDetector(configLanguageDetector);
export default languageDetector; export default languageDetector;

View File

@ -1,11 +1,11 @@
// @flow
import { SET_DYNAMIC_BRANDING_DATA } from '../../dynamic-branding/actionTypes'; import { SET_DYNAMIC_BRANDING_DATA } from '../../dynamic-branding/actionTypes';
import { MiddlewareRegistry } from '../redux'; import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import { I18NEXT_INITIALIZED, LANGUAGE_CHANGED } from './actionTypes'; import { I18NEXT_INITIALIZED, LANGUAGE_CHANGED } from './actionTypes';
import { changeLanguageBundle } from './functions'; import { changeLanguageBundle } from './functions';
import i18next from './i18next'; import i18next from './i18next';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import logger from './logger'; import logger from './logger';
/** /**

View File

@ -10,7 +10,8 @@
"moduleResolution": "Node", "moduleResolution": "Node",
"strict": true, "strict": true,
"noImplicitAny": true, "noImplicitAny": true,
"strictPropertyInitialization": false "strictPropertyInitialization": false,
"resolveJsonModule": true
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"