UNPKG

@rockpack/localazer

Version:

This module can help you organize localization in your React application

69 lines (68 loc) 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var jed_1 = require("./jed"); var localeData = { domain: 'messages', // eslint-disable-next-line @typescript-eslint/camelcase locale_data: { messages: { '': { domain: 'messages', // eslint-disable-next-line @typescript-eslint/camelcase plural_forms: 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);', lang: 'ru' }, 'Alarm!': ['Ахтунг!'], 'Hello world': ['Привет мир'], '%d click': ['%d клик', '%d кликов', '%d кликов'], 'Sort By': ['Сортировать по'], Latest: ['По последнему'], 'Most Popular': ['Самый популярный'], 'Most Viewed': ['Самый просматриваемый'], 'Most Commented': ['Самый комментируемый'], 'USER\u0004Your name is %s and surname is %s': ['Ваше имя %s ваша фамилия %s'] } } }; beforeAll(function () { jed_1.i18n.options = localeData; }); test('"l" test. Hello world -> Привет мир', function () { expect(jed_1.l('Hello world')()).toBe('Привет мир'); }); test('"l" test. Alarm! -> Ахтунг!', function () { expect(jed_1.l('Alarm!')()) .toBe('Ахтунг!'); }); test('"l" test. Default variant', function () { var defaultString = 'I am default'; expect(jed_1.l(defaultString)()) .toBe(defaultString); }); test('nl plural with zero test', function () { expect(jed_1.nl('%d click', '%d clicks', 0)()) .toBe('%d кликов'); }); test('nl singular test', function () { expect(jed_1.nl('%d click', '%d clicks', 1)()) .toBe('%d клик'); }); test('nl plural with many test', function () { expect(jed_1.nl('%d click', '%d clicks', 123)()) .toBe('%d кликов'); }); test('sprintf pass 0 variable to nl', function () { var count = 0; expect(jed_1.sprintf(jed_1.nl('%d click', '%d clicks', count)(), count)()) .toBe('0 кликов'); }); test('sprintf pass 1 variable to nl', function () { var count = 1; expect(jed_1.sprintf(jed_1.nl('%d click', '%d clicks', count)(), count)()) .toBe('1 клик'); }); test('sprintf pass 123 variable to nl', function () { var count = 123; expect(jed_1.sprintf(jed_1.nl('%d click', '%d clicks', count)(), count)()) .toBe('123 кликов'); });