Skip to content

Commit

Permalink
Merge pull request ivmartel#1053 from ivmartel/1049-use-i18next-http
Browse files Browse the repository at this point in the history
Replace i18next-xhr-backend with i18next-http-backend
  • Loading branch information
ivmartel authored Dec 10, 2021
2 parents bfae61d + e8fb2f5 commit 8dd734b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function (config) {
{pattern: 'node_modules/konva/konva.min.js', watched: false},
{pattern: 'node_modules/i18next/i18next.min.js', watched: false},
{
pattern: 'node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js',
pattern: 'node_modules/i18next-http-backend/i18nextHttpBackend.min.js',
watched: false
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"i18next": "~20.6.0",
"i18next-browser-languagedetector": "~6.1.2",
"i18next-xhr-backend": "~3.2.2",
"i18next-http-backend": "~1.3.1",
"jszip": "~3.7.0",
"konva": "~8.3.0",
"magic-wand-tool": "~1.1.7"
Expand Down
9 changes: 4 additions & 5 deletions resources/module/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// AMD. Register as an anonymous module.
define([
'i18next',
'i18next-xhr-backend',
'i18next-http-backend',
'i18next-browser-languagedetector',
'jszip',
'konva',
Expand All @@ -16,11 +16,10 @@
// only CommonJS-like environments that support module.exports,
// like Node.

// i18next-xhr-backend: requires XMlHttpRequest
// Konva: requires 'canvas'
module.exports = factory(
require('i18next'),
require('i18next-xhr-backend'),
require('i18next-http-backend'),
require('i18next-browser-languagedetector'),
require('jszip'),
require('konva/cmj'),
Expand All @@ -30,7 +29,7 @@
// Browser globals (root is window)
root.dwv = factory(
root.i18next,
root.i18nextXHRBackend,
root.i18nextHttpBackend,
root.i18nextBrowserLanguageDetector,
root.JSZip,
root.Konva,
Expand All @@ -39,7 +38,7 @@
}
}(this, function (
i18next,
i18nextXHRBackend,
i18nextHttpBackend,
i18nextBrowserLanguageDetector,
JSZip,
Konva,
Expand Down
12 changes: 6 additions & 6 deletions src/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ var dwv = dwv || {};
*/
var i18next = i18next || {};
/**
* The i18nextXHRBackend namespace.
* The i18nextHttpBackend namespace.
*
* @external i18nextXHRBackend
* @see https://github.com/i18next/i18next-xhr-backend
* @external i18nextHttpBackend
* @see https://github.com/i18next/i18next-http-backend
*/
var i18nextXHRBackend = i18nextXHRBackend || {};
var i18nextHttpBackend = i18nextHttpBackend || {};
/**
* The i18nextBrowserLanguageDetector namespace.
*
Expand Down Expand Up @@ -47,8 +47,8 @@ dwv.i18nInitialise = function (language, localesPath) {
load: 'languageOnly',
backend: {loadPath: lpath + '/locales/{{lng}}/{{ns}}.json'}
};
// use the XHR backend to get translation files
var i18n = i18next.use(i18nextXHRBackend);
// use the HTTP backend to get translation files
var i18n = i18next.use(i18nextHttpBackend);
// use browser language or the specified one
if (lng === 'auto') {
i18n.use(i18nextBrowserLanguageDetector);
Expand Down
24 changes: 18 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037"
integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==

"@babel/runtime@^7.12.0", "@babel/runtime@^7.14.6", "@babel/runtime@^7.5.5":
"@babel/runtime@^7.12.0", "@babel/runtime@^7.14.6":
version "7.14.8"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.8.tgz#7119a56f421018852694290b9f9148097391b446"
integrity sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg==
Expand Down Expand Up @@ -1055,6 +1055,13 @@ create-error-class@^3.0.0:
dependencies:
capture-stack-trace "^1.0.0"

[email protected]:
version "3.1.4"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39"
integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==
dependencies:
node-fetch "2.6.1"

cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -2415,12 +2422,12 @@ i18next-browser-languagedetector@~6.1.2:
dependencies:
"@babel/runtime" "^7.14.6"

i18next-xhr-backend@~3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/i18next-xhr-backend/-/i18next-xhr-backend-3.2.2.tgz#769124441461b085291f539d91864e3691199178"
integrity sha512-OtRf2Vo3IqAxsttQbpjYnmMML12IMB5e0fc5B7qKJFLScitYaXa1OhMX0n0X/3vrfFlpHL9Ro/H+ps4Ej2j7QQ==
i18next-http-backend@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/i18next-http-backend/-/i18next-http-backend-1.3.1.tgz#c1175aaead22b62a70bdb556b794fef1ba558b3a"
integrity sha512-o79n4GBBRpl20hByC+ne/S1UaSZ4iGAn59Hu2TEZGjN0WLB72L7WrM39Cshziyrssp6MQfdI8wjToU2Q6kpSvA==
dependencies:
"@babel/runtime" "^7.5.5"
cross-fetch "3.1.4"

i18next@~20.6.0:
version "20.6.1"
Expand Down Expand Up @@ -3611,6 +3618,11 @@ node-fetch-npm@^2.0.2:
json-parse-better-errors "^1.0.0"
safe-buffer "^5.1.1"

[email protected]:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==

node-fetch@^1.7.3:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
Expand Down

0 comments on commit 8dd734b

Please sign in to comment.