translator.spec.js 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import test from 'tape'
  2. import Core from '../../src/core/index.js'
  3. import russian from '../../src/locales/ru_RU.js'
  4. import english from '../../src/locales/en_US.js'
  5. test('translation', function (t) {
  6. const core = new Core({locale: russian})
  7. t.equal(
  8. core.translator.translate('chooseFile'),
  9. 'Выберите файл',
  10. 'should return translated string'
  11. )
  12. t.end()
  13. })
  14. test('interpolation', function (t) {
  15. const core = new Core({locale: english})
  16. t.equal(
  17. core.translator.translate('youHaveChosen', {'fileName': '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 core = new Core({locale: russian})
  25. t.equal(
  26. core.translator.translate('filesChosen', {'smart_count': '18'}),
  27. 'Выбрано 18 файлов',
  28. 'should return interpolated & pluralized string'
  29. )
  30. t.end()
  31. })