translator.spec.js 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var test = require('tape');
  2. var Core = require('../src/core/index.js');
  3. test('russian translation', function (t) {
  4. const russian = require('../src/locale/ru.js');
  5. const core = new Core({locale: russian});
  6. t.equal(
  7. core.translator.t('choose_file'),
  8. 'Выберите файл',
  9. 'should return translated string'
  10. );
  11. t.end();
  12. });
  13. test('interpolation', function (t) {
  14. const english = require('../src/locale/en_US.js');
  15. const core = new Core({locale: english});
  16. t.equal(
  17. core.translator.t('you_have_chosen', {'file_name': 'img.jpg'}),
  18. 'You have chosen: img.jpg',
  19. 'should return interpolated string'
  20. );
  21. t.end();
  22. });
  23. test('pluralization', function (t) {
  24. const russian = require('../src/locale/ru.js');
  25. const core = new Core({locale: russian});
  26. t.equal(
  27. core.translator.t('files_chosen', {'smart_count': '18'}),
  28. 'Выбрано 18 файлов',
  29. 'should return interpolated & pluralized string'
  30. );
  31. t.end();
  32. });