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';
/**
@ -212,7 +210,7 @@ const _LANGUAGES = {
// Register all builtin languages with the i18n library.
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(
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.

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.
@ -57,7 +57,7 @@ export default {
* @param {string} language - Language.
* @returns {string} The normalized language.
*/
function normalizeLanguage(language) {
function normalizeLanguage(language: string) {
const [ lang, variant ] = language.replace('_', '-').split('-');
if (!variant || lang === variant) {

View File

@ -1,5 +1,3 @@
// @flow
import moment from 'moment';
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
// more than an hour long
// @ts-ignore
if (moment.duration(duration).format('h') !== '0') {
// @ts-ignore
return moment.duration(duration).format('h:mm:ss');
}
// @ts-ignore
return moment.duration(duration).format('mm:ss', { trim: false });
}

View File

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

View File

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

View File

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

View File

@ -1,12 +1,10 @@
/* @flow */
import BrowserLanguageDetector from 'i18next-browser-languagedetector';
import configLanguageDetector from './configLanguageDetector';
import customNavigatorDetector from './customNavigatorDetector';
declare var interfaceConfig: Object;
// eslint-disable-next-line no-var
declare var interfaceConfig: any;
/**
* 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
// order has already been established above.
// @ts-ignore
languageDetector.addDetector(customNavigatorDetector);
// @ts-ignore
languageDetector.addDetector(configLanguageDetector);
export default languageDetector;

View File

@ -1,11 +1,11 @@
// @flow
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 { changeLanguageBundle } from './functions';
import i18next from './i18next';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import logger from './logger';
/**

View File

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