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

New language handling #2216

Open
wants to merge 2 commits 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"date-fns": "^2.30.0",
"downshift": "^3.2.2",
"eslint": "^8.57.0",
"i18next": "^23.5.1",
"i18next": "^23.11.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lerna": "^7.1.4",
Expand All @@ -103,7 +103,7 @@
"react-device-detect": "^2.2.3",
"react-dom": "^18.3.0",
"react-helmet-async": "^1.3.0",
"react-i18next": "^13.3.0",
"react-i18next": "^14.1.1",
"react-router-dom": "^6.3.0",
"sass": "^1.62.0",
"sass-loader": "^13.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/article-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"i18next": ">= 23.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0",
"react-i18next": "^14.0.0",
"react-router-dom": ">= 6.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"devDependencies": {
"@ndla/types-embed": "^4.1.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-howto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"i18next": ">= 23.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": ">= 13.0.0",
"react-i18next": ">= 14.0.0",
"react-router-dom": ">= 6.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-image-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"i18next": ">= 23.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": ">= 13.0.0",
"react-i18next": ">= 14.0.0",
"react-router-dom": ">= 6.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/ndla-notion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions packages/ndla-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"@radix-ui/react-slider": "^1.1.2",
"date-fns": "^2.30.0",
"html-react-parser": "^5.1.8",
"i18next-browser-languagedetector": "^7.1.0",
"lodash.throttle": "^4.1.1",
"react-bem-helper": "1.4.1",
"react-device-detect": "^2.2.3",
Expand All @@ -67,7 +66,7 @@
"i18next": "^23.5.1",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0",
"react-i18next": "^14.0.0",
"react-router-dom": "> 6.0.0"
},
"devDependencies": {
Expand Down
10 changes: 1 addition & 9 deletions packages/ndla-ui/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@
*/

import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";
import messagesEN from "../locale/messages-en";
import messagesNB from "../locale/messages-nb";
import messagesNN from "../locale/messages-nn";
import messagesSE from "../locale/messages-se";
import messagesSMA from "../locale/messages-sma";

const DETECTION_OPTIONS = {
order: ["path", "localStorage", "htmlTag"],
caches: ["localStorage"],
lookupLocalStorage: "i18nextLng",
};

export const supportedTranslationLanguages = ["nb", "nn", "en", "se", "sma"] as const;
const i18nInstance = i18n.use(initReactI18next).use(LanguageDetector);
const i18nInstance = i18n.use(initReactI18next);

i18nInstance.init({
compatibilityJSON: "v3",
detection: DETECTION_OPTIONS,
fallbackLng: "nb",
supportedLngs: supportedTranslationLanguages,
resources: {
Expand Down
2 changes: 1 addition & 1 deletion packages/select/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/tooltip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@emotion/styled": "^11.10.4",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-i18next": "^13.3.0"
"react-i18next": "^14.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
66 changes: 28 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1549,12 +1549,12 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.19.4, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.22.5, @babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.4.5, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
version: 7.23.5
resolution: "@babel/runtime@npm:7.23.5"
"@babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.4.5, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
version: 7.24.4
resolution: "@babel/runtime@npm:7.24.4"
dependencies:
regenerator-runtime: "npm:^0.14.0"
checksum: 10c0/ca679cc91bb7e424bc2db87bb58cc3b06ade916b9adb21fbbdc43e54cdaacb3eea201ceba2a0464b11d2eb65b9fe6a6ffcf4d7521fa52994f19be96f1af14788
checksum: 10c0/785aff96a3aa8ff97f90958e1e8a7b1d47f793b204b47c6455eaadc3f694f48c97cd5c0a921fe3596d818e71f18106610a164fb0f1c71fd68c622a58269d537c
languageName: node
linkType: hard

Expand Down Expand Up @@ -2585,7 +2585,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand All @@ -2604,7 +2604,7 @@ __metadata:
i18next: ">= 23.0.0"
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
react-router-dom: ">= 6.0.0"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -2637,7 +2637,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2669,7 +2669,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2726,7 +2726,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2761,7 +2761,7 @@ __metadata:
i18next: ">= 23.0.0"
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ">= 13.0.0"
react-i18next: ">= 14.0.0"
react-router-dom: ">= 6.0.0"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -2797,7 +2797,7 @@ __metadata:
i18next: ">= 23.0.0"
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ">= 13.0.0"
react-i18next: ">= 14.0.0"
react-router-dom: ">= 6.0.0"
languageName: unknown
linkType: soft
Expand All @@ -2820,7 +2820,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand All @@ -2836,7 +2836,7 @@ __metadata:
"@emotion/react": ^11.10.4
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2892,7 +2892,7 @@ __metadata:
"@emotion/react": ^11.10.4
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2934,7 +2934,7 @@ __metadata:
"@emotion/styled": ^11.10.4
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -3016,7 +3016,6 @@ __metadata:
css-loader: "npm:^6.7.3"
date-fns: "npm:^2.30.0"
html-react-parser: "npm:^5.1.8"
i18next-browser-languagedetector: "npm:^7.1.0"
lodash.throttle: "npm:^4.1.1"
mini-css-extract-plugin: "npm:^2.7.5"
react-bem-helper: "npm:1.4.1"
Expand All @@ -3032,7 +3031,7 @@ __metadata:
i18next: ^23.5.1
react: ">= 16.8.0"
react-dom: ">= 16.8.0"
react-i18next: ^13.3.0
react-i18next: ^14.0.0
react-router-dom: "> 6.0.0"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -10771,7 +10770,7 @@ __metadata:
date-fns: "npm:^2.30.0"
downshift: "npm:^3.2.2"
eslint: "npm:^8.57.0"
i18next: "npm:^23.5.1"
i18next: "npm:^23.11.2"
jest: "npm:^29.7.0"
jest-environment-jsdom: "npm:^29.7.0"
lerna: "npm:^7.1.4"
Expand All @@ -10785,7 +10784,7 @@ __metadata:
react-device-detect: "npm:^2.2.3"
react-dom: "npm:^18.3.0"
react-helmet-async: "npm:^1.3.0"
react-i18next: "npm:^13.3.0"
react-i18next: "npm:^14.1.1"
react-router-dom: "npm:^6.3.0"
sass: "npm:^1.62.0"
sass-loader: "npm:^13.2.2"
Expand Down Expand Up @@ -11715,21 +11714,12 @@ __metadata:
languageName: node
linkType: hard

"i18next-browser-languagedetector@npm:^7.1.0":
version: 7.1.0
resolution: "i18next-browser-languagedetector@npm:7.1.0"
dependencies:
"@babel/runtime": "npm:^7.19.4"
checksum: 10c0/d7cd0ea0ad6047e786de665d67b41cbb0940a2983eb2c53dd85a5d71f88e170550bba8de45728470a2b5f88060bed2c79f330aff9806dd50ef58ade0ec7b8ca3
languageName: node
linkType: hard

"i18next@npm:^23.5.1":
version: 23.5.1
resolution: "i18next@npm:23.5.1"
"i18next@npm:^23.11.2":
version: 23.11.2
resolution: "i18next@npm:23.11.2"
dependencies:
"@babel/runtime": "npm:^7.22.5"
checksum: 10c0/af49c399a90505ae26c1a022d06c4a11c4adcde6524b31c315dcaa43443c85892adef6de934b2af737abbdd2ffa66449d2854f135af8691223a8bb4ffaf6e1af
"@babel/runtime": "npm:^7.23.2"
checksum: 10c0/1d33cc53eaa9e078534f8cf7fb2b79be5ec4314555ad1dafc5a5ff367b79ed1a735e9d17452f7bcc11777344e90613ebcf44ebc823e63c1036a6c26c35db014a
languageName: node
linkType: hard

Expand Down Expand Up @@ -16021,11 +16011,11 @@ __metadata:
languageName: node
linkType: hard

"react-i18next@npm:^13.3.0":
version: 13.3.0
resolution: "react-i18next@npm:13.3.0"
"react-i18next@npm:^14.1.1":
version: 14.1.1
resolution: "react-i18next@npm:14.1.1"
dependencies:
"@babel/runtime": "npm:^7.22.5"
"@babel/runtime": "npm:^7.23.9"
html-parse-stringify: "npm:^3.0.1"
peerDependencies:
i18next: ">= 23.2.3"
Expand All @@ -16035,7 +16025,7 @@ __metadata:
optional: true
react-native:
optional: true
checksum: 10c0/8c03ea4432fabb1cb3dc53fa7d04f8197600ada98a2c111ac8adf31baf3d0c23a0c1ee944d65c7c5b45deeabe52f625aed72d1bf2e60571ef6f22fd8e0391c81
checksum: 10c0/d6da148d5dd1635f57d7a85bdd5c6e1f1404982112358a5efa9f6f47d505a00e4650237d5fc94b4381dcb336c134d500268a7157e06e2b2f0293a2bcd7ec2812
languageName: node
linkType: hard

Expand Down
Loading