<commit_before>import { i18n } from '../src/ts/localization/i18n';

const fallbackTest = 'fallback test';
const successEn = 'success';
const successDe = 'erfolg';
const successIt = 'successo';

const defaultConfig = {
  language: 'en',
  browserLanguageDetection: false,
  translations: {
    'it': {
      'test': successIt,
      [fallbackTest]: successIt,
    },
    'en': {
      'test': successEn,
      [fallbackTest]: successEn,
    },
    'de': {
      'test': successDe,
    },
  },
};

describe('Localization', () => {
  beforeEach(() => {
    i18n.setConfig(defaultConfig);
  });

  describe('Locale initialiization', () => {
    it('uses vocabulary \'en\'', () => {
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successEn);
    });

    it('uses vocabulary \'de\'', () => {
      i18n.setConfig({ ...defaultConfig, language: 'de' });
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successDe);
    });

    it('uses vocabulary \'it\'', () => {
      i18n.setConfig({ ...defaultConfig, language: 'it' });
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successIt);
    });
  });

  describe('Language Fallback\'s', () => {
    it('falls back to `key` if it is not in vocabulary', () => {
      expect(i18n.getLocalizedText(i18n.t('some word'))).toEqual('some word');
    });

    it('falls back to', () => {
      i18n.setConfig({ ...defaultConfig, language: 'de' });
      expect(i18n.getLocalizedText(i18n.t(fallbackTest))).toEqual(successEn);
    });
  });
});<commit_msg>added variable test<commit_after>import { i18n } from '../src/ts/localization/i18n';

const fallbackTest = 'fallback test';
const successEn = 'success';
const successDe = 'erfolg';
const successIt = 'successo';

const defaultConfig = {
  language: 'en',
  browserLanguageDetection: false,
  translations: {
    'it': {
      'test': successIt,
      [fallbackTest]: successIt,
    },
    'en': {
      'test': successEn,
      [fallbackTest]: successEn,
      'variableTest': `{value}`,
    },
    'de': {
      'test': successDe,
    },
  },
};

describe('Localization', () => {
  beforeEach(() => {
    i18n.setConfig(defaultConfig);
  });

  describe('Locale initialiization', () => {
    it('uses vocabulary \'en\'', () => {
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successEn);
    });

    it('uses vocabulary \'de\'', () => {
      i18n.setConfig({ ...defaultConfig, language: 'de' });
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successDe);
    });

    it('uses vocabulary \'it\'', () => {
      i18n.setConfig({ ...defaultConfig, language: 'it' });
      expect(i18n.getLocalizedText(i18n.t('test'))).toEqual(successIt);
    });
  });

  describe('Language Fallback\'s', () => {
    it('falls back to `key` if it is not in vocabulary', () => {
      expect(i18n.getLocalizedText(i18n.t('some word'))).toEqual('some word');
    });

    it('falls back to', () => {
      i18n.setConfig({ ...defaultConfig, language: 'de' });
      expect(i18n.getLocalizedText(i18n.t(fallbackTest))).toEqual(successEn);
    });
  });


  describe('Variable Injection', () => {
    it ('injects the value to string passed by config', () => {
      expect(i18n.getLocalizedText(i18n.t('variableTest', { value: 1 }))).toEqual('1');
    });
  });
});
{'fraction_non_alphanumeric': 0.20752427184466019, 'fraction_numerical': 0.021237864077669904, 'mean_word_length': 3.304177545691906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7117874', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1120, 'n_words': 189}