@operato/i18n 0.3.21

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.
package/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
22
+
23
+ [*.json]
24
+ indent_size = 2
25
+
26
+ [*.{html,js,md}]
27
+ block_comment_start = /**
28
+ block_comment = *
29
+ block_comment_end = */
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
+ };
@@ -0,0 +1,8 @@
1
+ import { storybookPlugin } from '@web/dev-server-storybook';
2
+ import baseConfig from '../web-dev-server.config.mjs';
3
+
4
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
+ ...baseConfig,
6
+ open: '/',
7
+ plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
+ });
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ### [0.3.21](https://github.com/hatiolab/operato/compare/v0.3.20...v0.3.21) (2022-01-29)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * i18n module added, shell module started to cover client core part ([a976dad](https://github.com/hatiolab/operato/commit/a976dad6353962e489d8e648af9598b6a51e5ec7))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) hatiolab.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # \<ox-i18n>
2
+
3
+ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i i18n
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <script type="module">
15
+ import '@operato/i18n'
16
+ </script>
17
+
18
+ <ox-i18n></ox-i18n>
19
+ ```
20
+
21
+ ## Linting and formatting
22
+
23
+ To scan the project for linting and formatting errors, run
24
+
25
+ ```bash
26
+ npm run lint
27
+ ```
28
+
29
+ To automatically fix linting and formatting errors, run
30
+
31
+ ```bash
32
+ npm run format
33
+ ```
34
+
35
+ ## Testing with Web Test Runner
36
+
37
+ To execute a single test run:
38
+
39
+ ```bash
40
+ npm run test
41
+ ```
42
+
43
+ To run the tests in interactive watch mode run:
44
+
45
+ ```bash
46
+ npm run test:watch
47
+ ```
48
+
49
+ ## Demoing with Storybook
50
+
51
+ To run a local instance of Storybook for your component, run
52
+
53
+ ```bash
54
+ npm run storybook
55
+ ```
56
+
57
+ To build a production version of Storybook, run
58
+
59
+ ```bash
60
+ npm run storybook:build
61
+ ```
62
+
63
+ ## Tooling configs
64
+
65
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
66
+
67
+ If you customize the configuration a lot, you can consider moving them to individual files.
68
+
69
+ ## Local Demo with `web-dev-server`
70
+
71
+ ```bash
72
+ npm start
73
+ ```
74
+
75
+ To run a local development server that serves the basic demo located in `demo/index.html`
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <style>
6
+ body {
7
+ background: #fafafa;
8
+ }
9
+
10
+ #demo {
11
+ position: relative;
12
+ height: 100px;
13
+ background-color: lightgray;
14
+ text-align: center;
15
+ vertical-align: middle;
16
+ }
17
+ </style>
18
+ </head>
19
+ <body>
20
+ <div id="demo"></div>
21
+
22
+ <script type="module">
23
+ import { html, render } from 'lit'
24
+ import { i18next } from '../dist/src/config.js'
25
+ import '../dist/src/ox-i18n.js'
26
+ import '../dist/src/ox-i18n-selector.js'
27
+
28
+ const parent = document.querySelector('#demo')
29
+
30
+ render(
31
+ html`
32
+ Translated : <ox-i18n msgid="text.role_management"></ox-i18n>
33
+ <ox-i18n-seletor .value=${i18next.language || 'en-US'} @change=${e => {
34
+ var locale = e.detail
35
+ locale && i18next.changeLanguage(locale)
36
+ }}></ox-i18n-selector>
37
+ `,
38
+ parent
39
+ )
40
+ </script>
41
+ </body>
42
+ </html>
@@ -0,0 +1,3 @@
1
+ {
2
+ "text.role_management": "역할 관리"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "text.role_management": "역할 관리"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "text.role_management": "역할 관리"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "text.role_management": "역할 관리"
3
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export { default as i18next } from 'i18next';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import i18next from 'i18next';
5
+ import LngDetector from 'i18next-browser-languagedetector';
6
+ import HttpApi from 'i18next-http-backend';
7
+ i18next
8
+ .use(LngDetector)
9
+ .use(HttpApi)
10
+ .init({
11
+ fallbackLng: 'en',
12
+ debug: true,
13
+ ns: ['translations'],
14
+ defaultNS: 'translations',
15
+ keySeparator: false,
16
+ interpolation: {
17
+ prefix: '{',
18
+ suffix: '}'
19
+ },
20
+ load: 'languageOnly',
21
+ backend: {
22
+ loadPath: '/{ns}/{lng}.json'
23
+ },
24
+ detection: {
25
+ // order and from where user language should be detected
26
+ order: ['cookie'],
27
+ // keys or params to lookup language from
28
+ lookupCookie: 'i18next',
29
+ // cache user language on
30
+ caches: ['cookie'],
31
+ excludeCacheFor: ['cimode'],
32
+ // optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
33
+ cookieOptions: { path: '/', sameSite: 'strict' }
34
+ }
35
+ });
36
+ export { default as i18next } from 'i18next';
37
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,WAAW,MAAM,kCAAkC,CAAA;AAC1D,OAAO,OAAO,MAAM,sBAAsB,CAAA;AAE1C,OAAO;KACJ,GAAG,CAAC,WAAW,CAAC;KAChB,GAAG,CAAC,OAAO,CAAC;KACZ,IAAI,CAAC;IACJ,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,IAAI;IACX,EAAE,EAAE,CAAC,cAAc,CAAC;IACpB,SAAS,EAAE,cAAc;IACzB,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE;QACb,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;KACZ;IACD,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE;QACP,QAAQ,EAAE,kBAAkB;KAC7B;IACD,SAAS,EAAE;QACT,wDAAwD;QACxD,KAAK,EAAE,CAAC,QAAQ,CAAC;QAEjB,yCAAyC;QACzC,YAAY,EAAE,SAAS;QAEvB,yBAAyB;QACzB,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,eAAe,EAAE,CAAC,QAAQ,CAAC;QAE3B,qIAAqI;QACrI,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;KACjD;CACF,CAAC,CAAA;AAEJ,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport i18next from 'i18next'\nimport LngDetector from 'i18next-browser-languagedetector'\nimport HttpApi from 'i18next-http-backend'\n\ni18next\n .use(LngDetector)\n .use(HttpApi)\n .init({\n fallbackLng: 'en',\n debug: true,\n ns: ['translations'],\n defaultNS: 'translations',\n keySeparator: false,\n interpolation: {\n prefix: '{',\n suffix: '}'\n },\n load: 'languageOnly',\n backend: {\n loadPath: '/{ns}/{lng}.json'\n },\n detection: {\n // order and from where user language should be detected\n order: ['cookie'],\n\n // keys or params to lookup language from\n lookupCookie: 'i18next',\n\n // cache user language on\n caches: ['cookie'],\n excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)\n\n // optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)\n cookieOptions: { path: '/', sameSite: 'strict' }\n }\n })\n\nexport { default as i18next } from 'i18next'\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export * from './config';
5
+ export * from './localize';
6
+ export * from './ox-i18n';
7
+ export * from './ox-i18n-selector';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export * from './config';
5
+ export * from './localize';
6
+ export * from './ox-i18n';
7
+ export * from './ox-i18n-selector';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport * from './config'\nexport * from './localize'\nexport * from './ox-i18n'\nexport * from './ox-i18n-selector'\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { i18n } from 'i18next';
5
+ import { LitElement } from 'lit';
6
+ declare type Constructor<T = {}> = new (...args: any[]) => T;
7
+ export declare const localize: (i18next: i18n) => <T extends Constructor<LitElement>>(superClass: T) => Constructor<LitElement> & T;
8
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export const localize = (i18next) => (superClass) => {
5
+ class LocalizedElement extends superClass {
6
+ connectedCallback() {
7
+ var callback = () => {
8
+ this.languageUpdated && this.languageUpdated(i18next);
9
+ this.requestUpdate();
10
+ };
11
+ i18next.on('initialized', callback);
12
+ i18next.on('languageChanged', callback);
13
+ i18next.store.on('added', callback);
14
+ this.__i18next_callback__ = callback;
15
+ super.connectedCallback();
16
+ }
17
+ disconnectedCallback() {
18
+ super.connectedCallback();
19
+ i18next.off('initialized', this.__i18next_callback__);
20
+ i18next.off('languageChanged', this.__i18next_callback__);
21
+ i18next.store.off('added', this.__i18next_callback__);
22
+ }
23
+ }
24
+ return LocalizedElement;
25
+ };
26
+ //# sourceMappingURL=localize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../src/localize.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,CAAC,MAAM,QAAQ,GACnB,CAAC,OAAa,EAAE,EAAE,CAClB,CAAoC,UAAa,EAAE,EAAE;IACnD,MAAM,gBAAiB,SAAQ,UAAU;QAIvC,iBAAiB;YACf,IAAI,QAAQ,GAAG,GAAG,EAAE;gBAClB,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;gBACrD,IAAI,CAAC,aAAa,EAAE,CAAA;YACtB,CAAC,CAAA;YAED,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;YACnC,OAAO,CAAC,EAAE,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;YACvC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;YAEnC,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAA;YAEpC,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAC3B,CAAC;QAED,oBAAoB;YAClB,KAAK,CAAC,iBAAiB,EAAE,CAAA;YAEzB,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAA;YACrD,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAA;YACzD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAA;QACvD,CAAC;KACF;IAED,OAAO,gBAA+C,CAAA;AACxD,CAAC,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { i18n } from 'i18next'\nimport { LitElement } from 'lit'\n\ntype Constructor<T = {}> = new (...args: any[]) => T\n\nexport const localize =\n (i18next: i18n) =>\n <T extends Constructor<LitElement>>(superClass: T) => {\n class LocalizedElement extends superClass {\n private declare languageUpdated?: (i18next: i18n) => void\n private __i18next_callback__?: () => void\n\n connectedCallback() {\n var callback = () => {\n this.languageUpdated && this.languageUpdated(i18next)\n this.requestUpdate()\n }\n\n i18next.on('initialized', callback)\n i18next.on('languageChanged', callback)\n i18next.store.on('added', callback)\n\n this.__i18next_callback__ = callback\n\n super.connectedCallback()\n }\n\n disconnectedCallback() {\n super.connectedCallback()\n\n i18next.off('initialized', this.__i18next_callback__)\n i18next.off('languageChanged', this.__i18next_callback__)\n i18next.store.off('added', this.__i18next_callback__)\n }\n }\n\n return LocalizedElement as Constructor<LitElement> & T\n }\n"]}
@@ -0,0 +1,7 @@
1
+ import { LitElement } from 'lit-element';
2
+ export declare class I18nSelector extends LitElement {
3
+ static styles: import("lit-element").CSSResult;
4
+ value: string;
5
+ render(): import("lit-html").TemplateResult<1>;
6
+ onLocaleChanged(value: string): Promise<void>;
7
+ }
@@ -0,0 +1,67 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement } from 'lit-element';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { i18next } from './config';
5
+ let I18nSelector = class I18nSelector extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.value = '';
9
+ }
10
+ render() {
11
+ return html `
12
+ <select .value=${this.value} @change=${(e) => this.onLocaleChanged(e.target.value)}>
13
+ <option value="" ?selected=${!i18next.language}></option>
14
+ <option value="ms-MY" ?selected=${i18next.language == 'ms-MY'}>Bahasa Malaysia</option>
15
+ <option value="en-US" ?selected=${i18next.language == 'en-US'}>English</option>
16
+ <option value="ko-KR" ?selected=${i18next.language == 'ko-KR'}>한국어</option>
17
+ <option value="zh-CN" ?selected=${i18next.language == 'zh-CN'}>中文</option>
18
+ </select>
19
+ `;
20
+ }
21
+ async onLocaleChanged(value) {
22
+ if (!value) {
23
+ return;
24
+ }
25
+ this.value = value;
26
+ this.dispatchEvent(new CustomEvent('change', {
27
+ composed: true,
28
+ bubbles: true,
29
+ detail: value
30
+ }));
31
+ }
32
+ };
33
+ I18nSelector.styles = css `
34
+ * {
35
+ box-sizing: border-box;
36
+ }
37
+ *:focus {
38
+ outline: none;
39
+ }
40
+ select {
41
+ border: var(--i18n-selector-field-border, var(--input-field-border));
42
+ border-radius: var(--i18n-selector-field-border-radius, 0);
43
+ background-color: var(--i18n-selector-field-background-color, initial);
44
+ margin: var(--i18n-selector-field-margin, 0);
45
+ padding: var(--i18n-selector-field-padding, 0);
46
+ font: var(--i18n-selector-field-font, var(--input-field-font));
47
+ font-size: var(--i18n-selector-field-font-size, 15px);
48
+ width: var(--i18n-selector-field-width, 100%);
49
+ color: var(--i18n-selector-field-color, initial);
50
+ }
51
+ select:focus {
52
+ border: 1px solid var(--focus-background-color);
53
+ }
54
+
55
+ ::placeholder {
56
+ font-size: 0.8rem;
57
+ text-transform: capitalize;
58
+ }
59
+ `;
60
+ __decorate([
61
+ property({ type: String })
62
+ ], I18nSelector.prototype, "value", void 0);
63
+ I18nSelector = __decorate([
64
+ customElement('ox-i18n-selector')
65
+ ], I18nSelector);
66
+ export { I18nSelector };
67
+ //# sourceMappingURL=ox-i18n-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-i18n-selector.js","sourceRoot":"","sources":["../../src/ox-i18n-selector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGlC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QA6B8B,UAAK,GAAW,EAAE,CAAA;IA6BhD,CAAC;IA3BC,MAAM;QACJ,OAAO,IAAI,CAAA;uBACQ,IAAI,CAAC,KAAK,YAAY,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAE,CAAC,CAAC,MAAuB,CAAC,KAAK,CAAC;qCAC5E,CAAC,OAAO,CAAC,QAAQ;0CACZ,OAAO,CAAC,QAAQ,IAAI,OAAO;0CAC3B,OAAO,CAAC,QAAQ,IAAI,OAAO;0CAC3B,OAAO,CAAC,QAAQ,IAAI,OAAO;0CAC3B,OAAO,CAAC,QAAQ,IAAI,OAAO;;KAEhE,CAAA;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAa;QACjC,IAAI,CAAC,KAAK,EAAE;YACV,OAAM;SACP;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAElB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,KAAK;SACd,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AAzDQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAmB;AA7BnC,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA0DxB;SA1DY,YAAY","sourcesContent":["import { css, html, LitElement } from 'lit-element'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from './config'\n\n@customElement('ox-i18n-selector')\nexport class I18nSelector extends LitElement {\n static styles = css`\n * {\n box-sizing: border-box;\n }\n *:focus {\n outline: none;\n }\n select {\n border: var(--i18n-selector-field-border, var(--input-field-border));\n border-radius: var(--i18n-selector-field-border-radius, 0);\n background-color: var(--i18n-selector-field-background-color, initial);\n margin: var(--i18n-selector-field-margin, 0);\n padding: var(--i18n-selector-field-padding, 0);\n font: var(--i18n-selector-field-font, var(--input-field-font));\n font-size: var(--i18n-selector-field-font-size, 15px);\n width: var(--i18n-selector-field-width, 100%);\n color: var(--i18n-selector-field-color, initial);\n }\n select:focus {\n border: 1px solid var(--focus-background-color);\n }\n\n ::placeholder {\n font-size: 0.8rem;\n text-transform: capitalize;\n }\n `\n\n @property({ type: String }) value: string = ''\n\n render() {\n return html`\n <select .value=${this.value} @change=${(e: Event) => this.onLocaleChanged((e.target as I18nSelector).value)}>\n <option value=\"\" ?selected=${!i18next.language}></option>\n <option value=\"ms-MY\" ?selected=${i18next.language == 'ms-MY'}>Bahasa Malaysia</option>\n <option value=\"en-US\" ?selected=${i18next.language == 'en-US'}>English</option>\n <option value=\"ko-KR\" ?selected=${i18next.language == 'ko-KR'}>한국어</option>\n <option value=\"zh-CN\" ?selected=${i18next.language == 'zh-CN'}>中文</option>\n </select>\n `\n }\n\n async onLocaleChanged(value: string) {\n if (!value) {\n return\n }\n\n this.value = value\n\n this.dispatchEvent(\n new CustomEvent('change', {\n composed: true,\n bubbles: true,\n detail: value\n })\n )\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { LitElement } from 'lit';
5
+ declare const OxI18n_base: (new (...args: any[]) => LitElement) & typeof LitElement;
6
+ export declare class OxI18n extends OxI18n_base {
7
+ msgid: string;
8
+ render(): import("lit-html").TemplateResult<1>;
9
+ }
10
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import { html, LitElement } from 'lit';
6
+ import { customElement, property } from 'lit/decorators.js';
7
+ import { i18next } from './config';
8
+ import { localize } from './localize';
9
+ let OxI18n = class OxI18n extends localize(i18next)(LitElement) {
10
+ render() {
11
+ return html `${i18next.t(this.msgid)}`;
12
+ }
13
+ };
14
+ __decorate([
15
+ property({ type: String })
16
+ ], OxI18n.prototype, "msgid", void 0);
17
+ OxI18n = __decorate([
18
+ customElement('ox-i18n')
19
+ ], OxI18n);
20
+ export { OxI18n };
21
+ //# sourceMappingURL=ox-i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-i18n.js","sourceRoot":"","sources":["../../src/ox-i18n.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,IAAa,MAAM,GAAnB,MAAa,MAAO,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAGvD,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;IACvC,CAAC;CACF,CAAA;AAL6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qCAAe;AAD/B,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAMlB;SANY,MAAM","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from './config'\nimport { localize } from './localize'\n\n@customElement('ox-i18n')\nexport class OxI18n extends localize(i18next)(LitElement) {\n @property({ type: String }) msgid!: string\n\n render() {\n return html`${i18next.t(this.msgid)}`\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/i18next/index.d.ts","../../../node_modules/i18next-browser-languagedetector/index.d.ts","../../../node_modules/i18next-http-backend/index.d.ts","../src/config.ts","../../../node_modules/@lit/reactive-element/css-tag.d.ts","../../../node_modules/@lit/reactive-element/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/reactive-element.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/@types/trusted-types/index.d.ts","../../../node_modules/lit-html/directive.d.ts","../../../node_modules/lit-html/lit-html.d.ts","../../../node_modules/lit-element/lit-element.d.ts","../../../node_modules/lit/index.d.ts","../src/localize.ts","../../../node_modules/@lit/reactive-element/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/decorators/custom-element.d.ts","../../../node_modules/@lit/reactive-element/decorators/property.d.ts","../../../node_modules/@lit/reactive-element/decorators/state.d.ts","../../../node_modules/@lit/reactive-element/decorators/event-options.d.ts","../../../node_modules/@lit/reactive-element/decorators/query.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-all.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-async.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-assigned-nodes.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-assigned-elements.d.ts","../../../node_modules/lit/decorators.d.ts","../src/ox-i18n.ts","../../../node_modules/lit-element/decorators.d.ts","../../../node_modules/lit-element/index.d.ts","../src/ox-i18n-selector.ts","../src/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/mocha/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","66d0fdc6d89df2f04eb0a85aa44214ae8b9e5e22317f72b090ece5dde333dd8f","332bd67a6233b14fd19c10d14110b12e5eea53ffe4a3a54e1eaf3c933e69d0e6","5fea664bb9db0da2781f8b89fd560bc93e70405caedb5099c9ec7c14b45cc026","035a263825cd9c1d965ce5062a6c5c0ecb7bf28699671deb659fac3c362c2ea7","6e2c5a9358c2be6791713f778c3af2d3357b8665d881e22f50b3aa861a2a9717","1e5743b25a63fd34ffbae89adcbf248ee17db6ed08d90079ffa93803c3e80d2a","adcf839acdeb840fc28b8f8afb9711e9a0c894bc6f24c27c81ec305ea6c24aff","2fcd2d22b1f30555e785105597cd8f57ed50300e213c4f1bbca6ae149f782c38",{"version":"bb4248c7f953233ac52332088fac897d62b82be07244e551d87c5049600b6cf7","affectsGlobalScope":true},"70f04c91d3186b1b10157157887fab664968fc9b88377785a5ee42750c202c6d","06e20da1bc94df355f22ac7a9533c2488816ec4cb9134d9b160a263629a07072","bece353ce2ed400f3a86b1f3beca6e973a64e5ce1c2143411469d8fbc88360cd","f07a77a7fb1d49aa2b61cb68bf712a083487acd7130d20223a83de03af0c257d","17959d175ba42127b555b990fb6ded437889f84d87c0ad446bd916ec3b06571f","97c58f6db61d45712d91d2260994817ae2b568bbb37cc280013079b6b5d2232d","ac388c7c7a262213a3700451bc921e382a93fb27c0252c34ccf03540b4ce044b","1da789e534bc558808021dd64abf33a91a68e422bbf28aeec236bd74df640401","fb0107c83e2e0e75b77dacd0c3c6c3ab6844e98dce2a8f858c6f0a57c12136a6","84610cf09dee3cefc910555318f1ad7b45f1cba36905a86849324ca4fead2385","a25d1e52291791819032826af5c52987e16ffdb96e8bb69f7f1790f5ab080be6","d660961abada6b5030461f3322ef3a2e1d9fec74167574f8b590a7796cf90a72","707b4eae3d469b2f347d2083037151922f94c370a9456ebd5ac0a4fb7441c7e7","1176aa92b37ccc58b8a1f99b58a76e8d65266ac03f4151062a412c00564a1e73","5b845f9c6dbd04fcb3e1af995363d2dcda308de24e982c97b249d5a661531db4","f0380f581cb015778c0fe51e95b5b7f6dae237280654558469b2486c1572268a","0b155b082e005c680a4fd252b75972d15a877d980a615d39465c34837e1d9e04","d448b94620192535dd3581cfdc57a2da54124681d4e035f403ff90b365ae58f1","3e96c96efad5d403b16c4b3d9cf99b3e86267a046abef94fe37cfa97ec013f23","f2eb05b1d521923bf78b9e09d14a2021802219a3369a649c8e035e306fac9db6","78a7a8d9a4d91c923ae1b5182823979f2856247b5008181f6254aff23356e61c","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"c2ab70bbc7a24c42a790890739dd8a0ba9d2e15038b40dff8163a97a5d148c00","affectsGlobalScope":true},"422dbb183fdced59425ca072c8bd09efaa77ce4e2ab928ec0d8a1ce062d2a45a",{"version":"2a801b0322994c3dd7f0ef30265d19b3dd3bae6d793596879166ed6219c3da68","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","98a3ebfa494b46265634a73459050befba5da8fdc6ca0ef9b7269421780f4ff3","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","cc0b61316c4f37393f1f9595e93b673f4184e9d07f4c127165a490ec4a928668","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"bfea28e6162ed21a0aeed181b623dcf250aa79abf49e24a6b7e012655af36d81","affectsGlobalScope":true},"7a5459efa09ea82088234e6533a203d528c594b01787fb90fba148885a36e8b6","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","10d4796a130577d57003a77b95d8723530bbec84718e364aa2129fa8ffba0378","ad41bb744149e92adb06eb953da195115620a3f2ad48e7d3ae04d10762dae197","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"5d0a9ea09d990b5788f867f1c79d4878f86f7384cb7dab38eecbf22f9efd063d","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","00fa7ce8bc8acc560dc341bbfdf37840a8c59e6a67c9bfa3fa5f36254df35db2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"cfe724f7c694aab65a9bdd1acb05997848c504548c9d4c71645c187a091cfa2a","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"3345c276cab0e76dda86c0fb79104ff915a4580ba0f3e440870e183b1baec476","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","e383ff72aabf294913f8c346f5da1445ae6ad525836d28efd52cbadc01a361a6","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7","1835259a20b9fa6b1882931375b69ae5978195f2b139b4e0db51ec8319261649","28a2e7383fd898c386ffdcacedf0ec0845e5d1a86b5a43f25b86bc315f556b79","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"0b3eba6dca8c6e534d16ef7b7d76cb546cd3cbab616c8f71daa0a151b5412b9e",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5,"useDefineForClassFields":false},"fileIdsList":[[114],[47,114],[55,114],[47,55,114],[47,55,63,114],[45,46,114],[71,114],[74,114],[75,80,114],[76,86,87,94,103,113,114],[76,77,86,94,114],[78,114],[79,80,87,95,114],[80,103,110,114],[81,83,86,94,114],[82,114],[83,84,114],[85,86,114],[86,114],[86,87,88,103,113,114],[86,87,88,103,114],[89,94,103,113,114],[86,87,89,90,94,103,110,113,114],[89,91,103,110,113,114],[71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120],[86,92,114],[93,113,114],[83,86,94,103,114],[95,114],[96,114],[74,97,114],[98,112,114,118],[99,114],[100,114],[86,101,114],[101,102,114,116],[86,103,104,105,114],[103,105,114],[103,104,114],[106,114],[107,114],[86,108,109,114],[108,109,114],[80,94,103,110,114],[111,114],[94,112,114],[75,89,100,113,114],[80,114],[103,114,115],[114,116],[114,117],[75,80,86,88,97,103,113,114,116,118],[103,114,119],[48,114],[41,42,43,114],[55,56,57,58,59,60,61,62,63,64,114],[47,51,52,67,114],[47,51,114],[51,114],[49,50,114],[56,57,58,59,60,61,62,63,64,114],[47,51,52,114],[40,41,42,43,114],[40,44,54,66,69,114],[40,41,42,43,53,114],[40,44,65,68,114],[40,44,53,54,65,114]],"referencedMap":[[45,1],[55,2],[56,3],[59,4],[57,4],[61,4],[64,5],[63,1],[62,4],[60,4],[58,3],[46,1],[47,6],[122,1],[71,7],[72,7],[74,8],[75,9],[76,10],[77,11],[78,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,17],[85,18],[86,19],[87,20],[88,21],[73,1],[120,1],[89,22],[90,23],[91,24],[121,25],[92,26],[93,27],[94,28],[95,29],[96,30],[97,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[105,38],[104,39],[106,40],[107,41],[108,42],[109,43],[110,44],[111,45],[112,46],[113,47],[114,48],[115,49],[116,50],[117,51],[118,52],[119,53],[49,54],[48,1],[42,55],[43,55],[41,1],[67,56],[68,57],[52,58],[50,59],[51,60],[65,61],[53,62],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[44,63],[70,64],[54,65],[69,66],[66,67]],"exportedModulesMap":[[45,1],[55,2],[56,3],[59,4],[57,4],[61,4],[64,5],[63,1],[62,4],[60,4],[58,3],[46,1],[47,6],[122,1],[71,7],[72,7],[74,8],[75,9],[76,10],[77,11],[78,12],[79,13],[80,14],[81,15],[82,16],[83,17],[84,17],[85,18],[86,19],[87,20],[88,21],[73,1],[120,1],[89,22],[90,23],[91,24],[121,25],[92,26],[93,27],[94,28],[95,29],[96,30],[97,31],[98,32],[99,33],[100,34],[101,35],[102,36],[103,37],[105,38],[104,39],[106,40],[107,41],[108,42],[109,43],[110,44],[111,45],[112,46],[113,47],[114,48],[115,49],[116,50],[117,51],[118,52],[119,53],[49,54],[48,1],[42,55],[43,55],[41,1],[67,56],[68,57],[52,58],[50,59],[51,60],[65,61],[53,62],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[44,63],[70,64],[54,65],[69,66],[66,67]],"semanticDiagnosticsPerFile":[45,55,56,59,57,61,64,63,62,60,58,46,47,122,71,72,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,73,120,89,90,91,121,92,93,94,95,96,97,98,99,100,101,102,103,105,104,106,107,108,109,110,111,112,113,114,115,116,117,118,119,49,48,42,43,41,67,68,52,50,51,65,53,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,44,70,54,69,66]},"version":"4.5.5"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@operato/i18n",
3
+ "description": "Webcomponent i18n following open-wc recommendations",
4
+ "license": "MIT",
5
+ "author": "heartyoh",
6
+ "version": "0.3.21",
7
+ "main": "dist/src/index.js",
8
+ "module": "dist/src/index.js",
9
+ "exports": {
10
+ ".": "./dist/src/index.js",
11
+ "./ox-i18n.js": "./dist/src/ox-i18n.js",
12
+ "./ox-i18n-selector.js": "./dist/src/ox-i18n-selector.js",
13
+ "./config.js": "./dist/src/config.js",
14
+ "./localize.js": "./dist/src/localize.js"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "@operato:registry": "https://registry.npmjs.org"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/hatiolab/operato.git",
23
+ "directory": "webcomponents/i18n"
24
+ },
25
+ "scripts": {
26
+ "analyze": "cem analyze --litelement",
27
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
28
+ "build": "tsc && npm run analyze -- --exclude dist",
29
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
30
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
31
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
32
+ "test": "tsc && wtr --coverage",
33
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
34
+ "storybook": "tsc && npm run analyze -- --exclude dist && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds -c .storybook/server.mjs\"",
35
+ "storybook:build": "tsc && npm run analyze -- --exclude dist && build-storybook"
36
+ },
37
+ "dependencies": {
38
+ "@web/dev-server-esbuild": "^0.2.16",
39
+ "i18next": "^21.6.10",
40
+ "i18next-browser-languagedetector": "^6.1.3",
41
+ "i18next-http-backend": "^1.3.2",
42
+ "lit": "^2.0.2"
43
+ },
44
+ "devDependencies": {
45
+ "@custom-elements-manifest/analyzer": "^0.4.17",
46
+ "@hatiolab/prettier-config": "^1.0.0",
47
+ "@open-wc/eslint-config": "^4.3.0",
48
+ "@open-wc/testing": "next",
49
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
50
+ "@typescript-eslint/parser": "^4.33.0",
51
+ "@web/dev-server": "^0.1.29",
52
+ "@web/dev-server-storybook": "next",
53
+ "@web/test-runner": "next",
54
+ "concurrently": "^5.3.0",
55
+ "eslint": "^7.32.0",
56
+ "eslint-config-prettier": "^8.3.0",
57
+ "husky": "^4.3.8",
58
+ "lint-staged": "^10.5.4",
59
+ "prettier": "^2.4.1",
60
+ "tslib": "^2.3.1",
61
+ "typescript": "^4.5.2"
62
+ },
63
+ "customElements": "custom-elements.json",
64
+ "prettier": "@hatiolab/prettier-config",
65
+ "husky": {
66
+ "hooks": {
67
+ "pre-commit": "lint-staged"
68
+ }
69
+ },
70
+ "lint-staged": {
71
+ "*.ts": [
72
+ "eslint --fix",
73
+ "prettier --write"
74
+ ]
75
+ },
76
+ "gitHead": "defcbbc48c0e5404961a5ba854c9f8efbd7412d1"
77
+ }
package/src/config.ts ADDED
@@ -0,0 +1,42 @@
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 as i18next } from 'i18next'
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ export * from './config'
6
+ export * from './localize'
7
+ export * from './ox-i18n'
8
+ export * from './ox-i18n-selector'
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { i18n } from 'i18next'
6
+ import { LitElement } from 'lit'
7
+
8
+ type Constructor<T = {}> = new (...args: any[]) => T
9
+
10
+ export const localize =
11
+ (i18next: i18n) =>
12
+ <T extends Constructor<LitElement>>(superClass: T) => {
13
+ class LocalizedElement extends superClass {
14
+ private declare languageUpdated?: (i18next: i18n) => void
15
+ private __i18next_callback__?: () => void
16
+
17
+ connectedCallback() {
18
+ var callback = () => {
19
+ this.languageUpdated && this.languageUpdated(i18next)
20
+ this.requestUpdate()
21
+ }
22
+
23
+ i18next.on('initialized', callback)
24
+ i18next.on('languageChanged', callback)
25
+ i18next.store.on('added', callback)
26
+
27
+ this.__i18next_callback__ = callback
28
+
29
+ super.connectedCallback()
30
+ }
31
+
32
+ disconnectedCallback() {
33
+ super.connectedCallback()
34
+
35
+ i18next.off('initialized', this.__i18next_callback__)
36
+ i18next.off('languageChanged', this.__i18next_callback__)
37
+ i18next.store.off('added', this.__i18next_callback__)
38
+ }
39
+ }
40
+
41
+ return LocalizedElement as Constructor<LitElement> & T
42
+ }
@@ -0,0 +1,65 @@
1
+ import { css, html, LitElement } from 'lit-element'
2
+ import { customElement, property } from 'lit/decorators.js'
3
+
4
+ import { i18next } from './config'
5
+
6
+ @customElement('ox-i18n-selector')
7
+ export class I18nSelector extends LitElement {
8
+ static styles = css`
9
+ * {
10
+ box-sizing: border-box;
11
+ }
12
+ *:focus {
13
+ outline: none;
14
+ }
15
+ select {
16
+ border: var(--i18n-selector-field-border, var(--input-field-border));
17
+ border-radius: var(--i18n-selector-field-border-radius, 0);
18
+ background-color: var(--i18n-selector-field-background-color, initial);
19
+ margin: var(--i18n-selector-field-margin, 0);
20
+ padding: var(--i18n-selector-field-padding, 0);
21
+ font: var(--i18n-selector-field-font, var(--input-field-font));
22
+ font-size: var(--i18n-selector-field-font-size, 15px);
23
+ width: var(--i18n-selector-field-width, 100%);
24
+ color: var(--i18n-selector-field-color, initial);
25
+ }
26
+ select:focus {
27
+ border: 1px solid var(--focus-background-color);
28
+ }
29
+
30
+ ::placeholder {
31
+ font-size: 0.8rem;
32
+ text-transform: capitalize;
33
+ }
34
+ `
35
+
36
+ @property({ type: String }) value: string = ''
37
+
38
+ render() {
39
+ return html`
40
+ <select .value=${this.value} @change=${(e: Event) => this.onLocaleChanged((e.target as I18nSelector).value)}>
41
+ <option value="" ?selected=${!i18next.language}></option>
42
+ <option value="ms-MY" ?selected=${i18next.language == 'ms-MY'}>Bahasa Malaysia</option>
43
+ <option value="en-US" ?selected=${i18next.language == 'en-US'}>English</option>
44
+ <option value="ko-KR" ?selected=${i18next.language == 'ko-KR'}>한국어</option>
45
+ <option value="zh-CN" ?selected=${i18next.language == 'zh-CN'}>中文</option>
46
+ </select>
47
+ `
48
+ }
49
+
50
+ async onLocaleChanged(value: string) {
51
+ if (!value) {
52
+ return
53
+ }
54
+
55
+ this.value = value
56
+
57
+ this.dispatchEvent(
58
+ new CustomEvent('change', {
59
+ composed: true,
60
+ bubbles: true,
61
+ detail: value
62
+ })
63
+ )
64
+ }
65
+ }
package/src/ox-i18n.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { html, LitElement } from 'lit'
6
+ import { customElement, property } from 'lit/decorators.js'
7
+
8
+ import { i18next } from './config'
9
+ import { localize } from './localize'
10
+
11
+ @customElement('ox-i18n')
12
+ export class OxI18n extends localize(i18next)(LitElement) {
13
+ @property({ type: String }) msgid!: string
14
+
15
+ render() {
16
+ return html`${i18next.t(this.msgid)}`
17
+ }
18
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "useDefineForClassFields": false,
13
+ "importHelpers": true,
14
+ "outDir": "dist",
15
+ "sourceMap": true,
16
+ "inlineSources": true,
17
+ "rootDir": "./",
18
+ "declaration": true,
19
+ "incremental": true,
20
+ "types": ["node", "mocha"]
21
+ },
22
+ "include": ["**/*.ts"]
23
+ }
@@ -0,0 +1,27 @@
1
+ // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
+
3
+ /** Use Hot Module replacement by adding --hmr to the start command */
4
+ const hmr = process.argv.includes('--hmr')
5
+
6
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ open: '/demo/',
8
+ /** Use regular watch mode if HMR is not enabled. */
9
+ watch: !hmr,
10
+ /** Resolve bare module imports */
11
+ nodeResolve: {
12
+ exportConditions: ['browser', 'development']
13
+ },
14
+
15
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
+ esbuildTarget: 'auto',
17
+
18
+ /** Set appIndex to enable SPA routing */
19
+ // appIndex: 'demo/index.html',
20
+
21
+ plugins: [
22
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
+ ]
25
+
26
+ // See documentation for all available options
27
+ })
@@ -0,0 +1,41 @@
1
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
2
+
3
+ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
+
5
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
+ /** Test files to run */
7
+ files: 'dist/test/**/*.test.js',
8
+
9
+ /** Resolve bare module imports */
10
+ nodeResolve: {
11
+ exportConditions: ['browser', 'development'],
12
+ },
13
+
14
+ /** Filter out lit dev mode logs */
15
+ filterBrowserLogs(log) {
16
+ for (const arg of log.args) {
17
+ if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ },
23
+
24
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
+ // esbuildTarget: 'auto',
26
+
27
+ /** Amount of browsers to run concurrently */
28
+ // concurrentBrowsers: 2,
29
+
30
+ /** Amount of test files per browser to test concurrently */
31
+ // concurrency: 1,
32
+
33
+ /** Browsers to run tests on */
34
+ // browsers: [
35
+ // playwrightLauncher({ product: 'chromium' }),
36
+ // playwrightLauncher({ product: 'firefox' }),
37
+ // playwrightLauncher({ product: 'webkit' }),
38
+ // ],
39
+
40
+ // See documentation for all available options
41
+ });