@things-factory/i18n-base 4.0.40 → 4.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,21 +2,8 @@
|
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { OxI18n } from '@operato/i18n/ox-i18n.js'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import { localize } from '../mixins/localize-mixin'
|
|
9
|
-
|
|
10
|
-
export default class I18nMsg extends localize(i18next)(LitElement) {
|
|
11
|
-
static get properties() {
|
|
12
|
-
return {
|
|
13
|
-
msgid: { attribute: true }
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
render() {
|
|
18
|
-
return html`${i18next.t(this.msgid)}`
|
|
19
|
-
}
|
|
20
|
-
}
|
|
7
|
+
class I18nMsg extends OxI18n {}
|
|
21
8
|
|
|
22
9
|
customElements.define('i18n-msg', I18nMsg)
|
package/client/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/i18n-base",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.44",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,10 +24,8 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"i18next-browser-languagedetector": "^6.1.2",
|
|
30
|
-
"i18next-http-backend": "^1.3.1"
|
|
27
|
+
"@operato/i18n": "^0.3.27",
|
|
28
|
+
"@things-factory/shell": "^4.0.44"
|
|
31
29
|
},
|
|
32
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "286a037443bfb38c65db964dbfa6c5f2d141d9ac"
|
|
33
31
|
}
|
package/client/i18next-config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import i18next from 'i18next'
|
|
6
|
-
import LngDetector from 'i18next-browser-languagedetector'
|
|
7
|
-
import HttpApi from 'i18next-http-backend'
|
|
8
|
-
|
|
9
|
-
i18next
|
|
10
|
-
.use(LngDetector)
|
|
11
|
-
.use(HttpApi)
|
|
12
|
-
.init({
|
|
13
|
-
fallbackLng: 'en',
|
|
14
|
-
debug: true,
|
|
15
|
-
ns: ['translations'],
|
|
16
|
-
defaultNS: 'translations',
|
|
17
|
-
keySeparator: false,
|
|
18
|
-
interpolation: {
|
|
19
|
-
prefix: '{',
|
|
20
|
-
suffix: '}'
|
|
21
|
-
},
|
|
22
|
-
load: 'languageOnly',
|
|
23
|
-
backend: {
|
|
24
|
-
loadPath: '/{ns}/{lng}.json'
|
|
25
|
-
},
|
|
26
|
-
detection: {
|
|
27
|
-
// order and from where user language should be detected
|
|
28
|
-
order: ['cookie'],
|
|
29
|
-
|
|
30
|
-
// keys or params to lookup language from
|
|
31
|
-
lookupCookie: 'i18next',
|
|
32
|
-
|
|
33
|
-
// cache user language on
|
|
34
|
-
caches: ['cookie'],
|
|
35
|
-
excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)
|
|
36
|
-
|
|
37
|
-
// optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
|
|
38
|
-
cookieOptions: { path: '/', sameSite: 'strict' }
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
export default i18next
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export const localize = i18next => baseElement =>
|
|
6
|
-
class extends baseElement {
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
var callback = () => {
|
|
9
|
-
this.languageUpdated && this.languageUpdated(i18next)
|
|
10
|
-
this.requestUpdate()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
i18next.on('initialized', callback)
|
|
14
|
-
i18next.on('languageChanged', callback)
|
|
15
|
-
i18next.store.on('added', callback)
|
|
16
|
-
|
|
17
|
-
this.__i18next_callback__ = callback
|
|
18
|
-
|
|
19
|
-
if (super.connectedCallback) {
|
|
20
|
-
super.connectedCallback()
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
disconnectedCallback() {
|
|
25
|
-
if (super.connectedCallback) {
|
|
26
|
-
super.connectedCallback()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
i18next.store.off('initialized', this.__i18next_callback__)
|
|
30
|
-
i18next.store.off('languageChanged', this.__i18next_callback__)
|
|
31
|
-
i18next.store.off('added', this.__i18next_callback__)
|
|
32
|
-
}
|
|
33
|
-
}
|