How to use the i18n-js.translations function in i18n-js

To help you get started, we’ve selected a few i18n-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sage / carbon / src / components / i18n / i18n.stories.js View on Github external
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 (
      
    );
  };
github ck3g / BlitzReading / src / i18n.js View on Github external
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;
github bytefury / crater-mobile / src / api / lang / i18n.js View on Github external
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;
github burst-apps-team / phoenix / mobile / src / core / i18n.ts View on Github external
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;
github Vivify-Ideas / expo-boilerplate / i18n / index.js View on Github external
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);
}
github Sage / carbon / src / __experimental__ / components / decimal / decimal.spec.js View on Github external
beforeAll(() => {
    translations = { ...I18n.translations };
    I18n.translations.fr = {
      number: {
        format: {
          delimiter: '.',
          separator: ','
        }
      }
    };
  });
github rastapasta / foodsharing / src / common / translation.tsx View on Github external
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)
}
github Sage / carbon / src / utils / validations / numeral / numeral-type / __spec__.js View on Github external
beforeEach(() => {
    I18n.translations = {
      en: {
        errors: {
          messages: {
            not_a_number: "Must be a valid decimal",
            not_an_integer: "Must be a valid integer"
          }
        }
      }
    };
  });