Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import { storiesOf } from '@storybook/react';
import { text, boolean } from '@storybook/addon-knobs';
import i18n from 'i18n-js';
import { dlsThemeSelector, classicThemeSelector } from '../../../.storybook/theme-selectors';
import { notes, Info } from './documentation';
import I18nComponent from './i18n';
import getDocGenInfo from '../../utils/helpers/docgen-info';
I18nComponent.__docgenInfo = getDocGenInfo(
require('./docgenInfo.json'),
/i18n\.js(?!spec)/
);
// eslint-disable-next-line dot-notation
i18n.translations.en['my'] = {
example: '# My __example__ translation.'
};
function makeStory(name, themeSelector) {
const component = () => {
const markdown = boolean('markdown', true);
const inline = markdown ? boolean('inline', I18nComponent.defaultProps.inline) : undefined;
const scope = text('scope', 'my.example');
return (
);
};
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 * as Localization from 'expo-localization';
import Lng from 'i18n-js';
import en from './en.json';
import fr from './fr.json';
import es from './es.json';
Lng.fallbacks = true;
Lng.translations = {
en,
fr,
es
};
Lng.locale = Localization.locale;
export default Lng;
import i18nJS from 'i18n-js';
import { findBestAvailableLanguage } from 'react-native-localize';
import en from '../translations/en.json';
import ru from '../translations/ru.json';
const fallback = { languageTag: 'en', isRTL: false };
const { languageTag } = findBestAvailableLanguage(['en-US', 'en', 'ru']) || fallback;
i18nJS.locale = languageTag;
i18nJS.fallbacks = true;
i18nJS.translations = { en, ru };
export const i18n = i18nJS;
import i18n from 'i18n-js';
import * as Localization from 'expo-localization';
import en from './locale/en';
i18n.fallbacks = true;
i18n.translations = {
en
};
i18n.locale = Localization.locale;
export default function $t(key, params = {}) {
return i18n.t(key, params);
}
beforeAll(() => {
translations = { ...I18n.translations };
I18n.translations.fr = {
number: {
format: {
delimiter: '.',
separator: ','
}
}
};
});
const setI18nConfig = () => {
const fallback = { languageTag: "en", isRTL: false }
const { languageTag, isRTL } =
RNLocalize.findBestAvailableLanguage(Object.keys(translationGetters)) ||
fallback
translate.cache.clear();
I18nManager.forceRTL(isRTL)
i18n.translations = { [languageTag]: translationGetters[languageTag]() }
i18n.locale = languageTag
moment.locale(languageTag)
}
beforeEach(() => {
I18n.translations = {
en: {
errors: {
messages: {
not_a_number: "Must be a valid decimal",
not_an_integer: "Must be a valid integer"
}
}
}
};
});