|
| 1 | +/* globals describe, it */ |
| 2 | + |
| 3 | +const { expect } = require('chai'); |
| 4 | +const { extractPhrases } = require('../../src/api/extract'); |
| 5 | + |
| 6 | +describe('extractPhrases with i18next parser', () => { |
| 7 | + it('works with json v4', async () => { |
| 8 | + expect(await extractPhrases('test/fixtures/i18next_v4.json', 'v4.json', { parser: 'i18next' })) |
| 9 | + .to.deep.equal({ |
| 10 | + 'keyDeep.inner': { |
| 11 | + string: 'value', |
| 12 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 13 | + }, |
| 14 | + key: { |
| 15 | + string: 'value', |
| 16 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 17 | + }, |
| 18 | + keyNesting: { |
| 19 | + string: 'reuse $t(keyDeep.inner)', |
| 20 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 21 | + }, |
| 22 | + keyInterpolate: { |
| 23 | + string: 'replace this {{value}}', |
| 24 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 25 | + }, |
| 26 | + keyInterpolateUnescaped: { |
| 27 | + string: 'replace this {{- value}}', |
| 28 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 29 | + }, |
| 30 | + keyInterpolateWithFormatting: { |
| 31 | + string: 'replace this {{value, format}}', |
| 32 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 33 | + }, |
| 34 | + keyContext_male: { |
| 35 | + string: 'the male variant', |
| 36 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 37 | + }, |
| 38 | + keyContext_female: { |
| 39 | + string: 'the female variant', |
| 40 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 41 | + }, |
| 42 | + keyPluralSimple_txplural: { |
| 43 | + string: '{count, plural, one {the singular} other {the plural}}', |
| 44 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 45 | + }, |
| 46 | + keyPluralMultipleEgArabic_zero: { |
| 47 | + string: 'the plural form 0', |
| 48 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 49 | + }, |
| 50 | + keyPluralMultipleEgArabic_txplural: { |
| 51 | + string: '{count, plural, one {the plural form 1} two {the plural form 2} few {the plural form 3} many {the plural form 4} other {the plural form 5}}', |
| 52 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 53 | + }, |
| 54 | + 'keyWithObjectValue.valueA': { |
| 55 | + string: 'return this with valueB', |
| 56 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 57 | + }, |
| 58 | + 'keyWithObjectValue.valueB': { |
| 59 | + string: 'more text', |
| 60 | + meta: { context: [], tags: [], occurrences: ['v4.json'] }, |
| 61 | + }, |
| 62 | + }); |
| 63 | + }); |
| 64 | +}); |
0 commit comments