Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for i18next v24 #1093

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to stop supporting v23 entirely instead?
If so, since that would be a breaking change, would it make sense to also move i18next to a peerDependency? It would help upstream projects with their dependency management.

Copy link
Author

@lazka lazka Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to stop supporting v23 entirely instead?

Your call. I seemed easy enough to support both, and it would make my life easier as I have various packages using i18next that depend on this, so I could update things gradually. But I'd be happy to change things if wanted.

If so, since that would be a breaking change, would it make sense to also move i18next to a peerDependency? It would help upstream projects with their dependency management.

I don't quite understand how peerDependency could help as I've never worked with that. Note that i18next-parser is importing/using i18next directly (

this.i18next = i18next.createInstance()
) and is not plugin as noted here: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#peerdependencies but maybe I'm missing something.

"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