Skip to content

Commit

Permalink
Merge pull request #1093 from lazka/v24-support
Browse files Browse the repository at this point in the history
Add support for i18next v24
  • Loading branch information
karellm authored Dec 26, 2024
2 parents 4f12240 + 29d04a2 commit e47955e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"esbuild": "^0.23.0",
"fs-extra": "^11.2.0",
"gulp-sort": "^2.0.0",
"i18next": "^23.5.1",
"i18next": "^23.5.1 || ^24.0.0",
"js-yaml": "^4.1.0",
"lilconfig": "^3.1.2",
"rsvp": "^4.8.5",
Expand Down
21 changes: 19 additions & 2 deletions test/parser.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert, expect } from 'chai'
import { fileURLToPath } from 'url'
import { createRequire } from 'module'
import fs from 'fs'
import path from 'path'
import sinon from 'sinon'
Expand All @@ -10,6 +11,12 @@ const enLibraryPath = path.normalize('en/translation.json')
const arLibraryPath = path.normalize('ar/translation.json')
const __dirname = path.dirname(fileURLToPath(import.meta.url))

function getI18NextMajorVersion() {
const require = createRequire(import.meta.url)
const pkg = require('i18next/package.json')
return pkg.version.split('.').map(Number)[0]
}

describe('parser', () => {
it('parses globally on multiple lines', (done) => {
let result
Expand Down Expand Up @@ -1688,7 +1695,12 @@ describe('parser', () => {
i18nextParser.end(fakeFile)
})

it('generates plurals according to compatibilityJSON value', (done) => {
it('generates plurals according to compatibilityJSON value', function (done) {
if (getI18NextMajorVersion() >= 24) {
// v24 only supports compatibilityJSON="v4"
this.skip()
}

let result
const i18nextParser = new i18nTransform({
i18nextOptions: { compatibilityJSON: 'v3' },
Expand All @@ -1714,7 +1726,12 @@ describe('parser', () => {
i18nextParser.end(fakeFile)
})

it('generates plurals according to compatibilityJSON value for languages with multiple plural forms', (done) => {
it('generates plurals according to compatibilityJSON value for languages with multiple plural forms', function (done) {
if (getI18NextMajorVersion() >= 24) {
// v24 only supports compatibilityJSON="v4"
this.skip()
}

let result
const i18nextParser = new i18nTransform({
locales: ['ar'],
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3072,10 +3072,10 @@ husky@^9.1.4:
resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.4.tgz#926fd19c18d345add5eab0a42b2b6d9a80259b34"
integrity sha512-bho94YyReb4JV7LYWRWxZ/xr6TtOTt8cMfmQ39MQYJ7f/YE268s3GdghGwi+y4zAeqewE5zYLvuhV0M0ijsDEA==

i18next@^23.5.1:
version "23.11.5"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-23.11.5.tgz#d71eb717a7e65498d87d0594f2664237f9e361ef"
integrity sha512-41pvpVbW9rhZPk5xjCX2TPJi2861LEig/YRhUkY+1FQ2IQPS0bKUDYnEqY8XPPbB48h1uIwLnP9iiEfuSl20CA==
"i18next@^23.5.1 || ^24.0.0":
version "24.0.5"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-24.0.5.tgz#2678986eca46411cae0329542a84dd4cd7e5f2f0"
integrity sha512-1jSdEzgFPGLZRsQwydoMFCBBaV+PmrVEO5WhANllZPX4y2JSGTxUjJ+xVklHIsiS95uR8gYc/y0hYZWevucNjg==
dependencies:
"@babel/runtime" "^7.23.2"

Expand Down

0 comments on commit e47955e

Please sign in to comment.