Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import lang from 'i18n-js';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import store from './store/configureStore';
import App from './dapp';
import init from './store/init';
import translations from './languages';
import './dapp.css';
// Init i18n translation
lang.defaultLocale = 'en';
lang.locale = navigator.language;
lang.fallbacks = true;
lang.translations = translations;
// Init Redux store
init();
render(
,
document.getElementById('app')
);
loadAudio = ({
audioID,
audioUUID,
localeOrder,
playAudioAfterLoad,
autoPlay,
}) => {
if (localeOrder == null) {
// Fallback to default locale, else play audio in Swedish.
localeOrder = [i18n.locale, i18n.defaultLocale, 'sv'];
}
return new Promise((resolve, reject) => {
const locale = localeOrder.shift();
const audioUrl = Platform.select({
ios: `audio/${audioID}/${audioID}${locale}.mp3`,
android: `audio_${audioID}${locale.toLowerCase()}.mp3`,
});
this.unloadAudio();
this._loadedSound = new Sound(audioUrl, Sound.MAIN_BUNDLE, error => {
if (error) {
this.unloadAudio();
if (localeOrder.length === 0) {
reject(`Cannot load file: ${audioUrl}`);
import en from './locales/en';
import pt from './locales/pt-BR';
// tslint:disable-next-line:no-require-imports
const I18nCreator = require('i18n-js');
I18nCreator.defaultLocale = 'en';
I18nCreator.fallbacks = true;
I18nCreator.translations = {
en: {...I18nCreator.translations.en, notification: en},
'pt-BR': {...I18nCreator.translations['pt-BR'], notification: pt},
};
export const I18n = I18nCreator;
export const appDidMount = app => {
// Load the current locale from extension settings
const state = app.getState();
const defaultLocale = 'en';
const { locale = defaultLocale } = getExtensionSettings(state, ext());
I18n.fallbacks = defaultLocale;
I18n.defaultLocale = defaultLocale;
I18n.locale = locale;
// Configure the moment library to use the same locale as the app
moment.locale(locale);
};
import './global';
import './shim';
import RNLanguages from 'react-native-languages';
import lang from 'i18n-js';
import { resources } from './src/languages';
// eslint-disable-next-line no-unused-vars,import/default
import App from './src/App';
// Languages (i18n)
lang.defaultLocale = 'en';
lang.locale = RNLanguages.language;
lang.fallbacks = true;
lang.translations = Object.assign(
{},
...Object.keys(resources).map(key => ({
[key]: resources[key].translation,
}))
);
// TODO
// don't load all translations in memory, when we have a lot of translations
// see
// https://github.com/react-native-community/react-native-localize/blob/master/example/src/AsyncExample.js
import * as RNLocalize from 'react-native-localize'
import I18n from 'i18n-js'
const de = require('./de.json')
const nl = require('./nl.json')
I18n.defaultLocale = 'en'
I18n.fallbacks = true
I18n.missingTranslation = scope => scope
I18n.translations = {
de,
nl,
}
export const locales = ['en', 'de', 'nl']
const fallback = { languageTag: 'en', isRTL: false }
const { languageTag } =
RNLocalize.findBestAvailableLanguage(locales) || fallback
I18n.locale = languageTag
const localeSpecificImages = {
en: {
'01.jpg': require('src/resources/img/en/01.jpg'),
I18n.autoDetectLocale = ({ defaultLocale }) => {
const userLocale = navigator.userLanguage || navigator.language;
I18n.defaultLocale = defaultLocale;
if (userLocale in I18n.translations) {
// exact locale is supported, use that
return (I18n.locale = userLocale);
}
const language = userLocale.match(/^[a-z]{2}/i)[0];
for (const locale in I18n.translations) {
if (locale.match(/^[a-z]{2}/i)[0] === language) {
// we've got a match on language, use that
return (I18n.locale = locale);
}
}
};
import * as RNLocalize from "react-native-localize";
import i18n from 'i18n-js';
import en from './locales.__generate__/en.json'
import vi from './locales.__generate__/vi.json'
i18n.defaultLocale = 'en';
i18n.locale = RNLocalize.getLocales()[0].languageTag;
i18n.fallbacks = true;
i18n.translations = { en, vi };
export default i18n;
import i18n from 'i18n-js';
import en from './locales/en.json';
import de from './locales/de.json';
i18n.defaultLocale = 'en';
i18n.locale = 'en';
i18n.fallbacks = true;
i18n.translations = { en, de };
export default i18n;
import React from "react"
import ReactDOM from 'react-dom'
import {Provider} from "react-redux"
import store from './state'
import I18n from "i18n-js"
import "./translations/en"
import App from "./components/App/App"
const rootEl = document.getElementById("root");
I18n.defaultLocale = "en";
I18n.locale = "en";
const renderComponent = (Component) => {
ReactDOM.render(
,
rootEl
);
};
renderComponent(App);