@omegagrid/localize 0.2.49

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.
@@ -0,0 +1,2 @@
1
+ export * from './localization';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./localization"), exports);
21
+ const localization_1 = require("./localization");
22
+ const locales_1 = __importDefault(require("./locales"));
23
+ locales_1.default.forEach(([locale, items]) => (0, localization_1.registerLocale)(locale, items));
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAE/B,iDAAgD;AAChD,wDAAgC;AAEhC,iBAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAA,6BAAc,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { LocalizeItem } from "..";
2
+ declare const _default: LocalizeItem[];
3
+ export default _default;
4
+ //# sourceMappingURL=cs-cz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cs-cz.d.ts","sourceRoot":"","sources":["../../src/locales/cs-cz.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;;AAElC,wBASoB"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [
4
+ { id: null, source: "copied", target: "zkopírováno" },
5
+ { id: null, source: "close", target: "zavřít" },
6
+ { id: null, source: "headers", target: "hlavičky" },
7
+ { id: null, source: "conditional formatting", target: "podmíněné formátování" },
8
+ { id: null, source: "sparklines", target: "mikrografy" },
9
+ { id: null, source: "named ranges", target: "pojmenované rozsahy" },
10
+ { id: null, source: "search", target: "hledat" },
11
+ { id: null, source: "load more", target: "načíst další" }
12
+ ];
13
+ //# sourceMappingURL=cs-cz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cs-cz.js","sourceRoot":"","sources":["../../src/locales/cs-cz.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACd,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAC;IACnD,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC;IAC7C,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAC;IACjD,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,uBAAuB,EAAC;IAC7E,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAC;IACtD,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,qBAAqB,EAAC;IACjE,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAC;IAC9C,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAC;CACrC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { LocalizeItem } from "..";
2
+ declare const _default: LocalizeItem[];
3
+ export default _default;
4
+ //# sourceMappingURL=en-us.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-us.d.ts","sourceRoot":"","sources":["../../src/locales/en-us.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;;AAElC,wBASoB"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [
4
+ { id: null, source: "copied", target: "copied" },
5
+ { id: null, source: "close", target: "close" },
6
+ { id: null, source: "headers", target: "headers" },
7
+ { id: null, source: "conditional formatting", target: "conditional formatting" },
8
+ { id: null, source: "sparklines", target: "sparklines" },
9
+ { id: null, source: "named ranges", target: "named ranges" },
10
+ { id: null, source: "search", target: "search" },
11
+ { id: null, source: "load more", target: "load more" }
12
+ ];
13
+ //# sourceMappingURL=en-us.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-us.js","sourceRoot":"","sources":["../../src/locales/en-us.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACd,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAC;IAC9C,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC;IAC5C,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAC;IAChD,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,wBAAwB,EAAC;IAC9E,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAC;IACtD,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAC;IAC1D,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAC;IAC9C,EAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAC;CAClC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { LocalizeItem } from '..';
2
+ declare const _default: [string, LocalizeItem[]][];
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,YAAY,EAAE,MAAM,IAAI,CAAC;;AAE5C,wBAMkC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const en_us_1 = __importDefault(require("./en-us"));
7
+ const cs_cz_1 = __importDefault(require("./cs-cz"));
8
+ exports.default = [
9
+ ['en-US', en_us_1.default],
10
+ ['en', en_us_1.default],
11
+ ['cs-CZ', cs_cz_1.default],
12
+ ['cs', cs_cz_1.default],
13
+ ['sk', cs_cz_1.default],
14
+ ];
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA2B;AAC3B,oDAA2B;AAG3B,kBAAe;IACd,CAAC,OAAO,EAAE,eAAI,CAAC;IACf,CAAC,IAAI,EAAE,eAAI,CAAC;IACZ,CAAC,OAAO,EAAE,eAAI,CAAC;IACf,CAAC,IAAI,EAAE,eAAI,CAAC;IACZ,CAAC,IAAI,EAAE,eAAI,CAAC;CACoB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export type LocaleId = string;
2
+ export type MsgOptions = {
3
+ /** Unique message id */
4
+ id?: string;
5
+ /** Description of this message */
6
+ desc?: string;
7
+ };
8
+ export type LocalizeItem = {
9
+ id: string;
10
+ source: string;
11
+ target: string;
12
+ };
13
+ export declare class LocaleChangeEvent extends Event {
14
+ locale: string;
15
+ constructor(locale: string);
16
+ }
17
+ export declare function getSystemLocale(): string;
18
+ export declare function registerLocale(locale: LocaleId | LocaleId[], items: LocalizeItem[]): void;
19
+ export declare function getLocale(): string;
20
+ export declare function hasLocale(locale: LocaleId): boolean;
21
+ export declare function setLocale(locale: LocaleId): void;
22
+ /**
23
+ * Translate a message to the current locale
24
+ * @param message source message
25
+ * @param _options reserved for future use
26
+ * @returns
27
+ */
28
+ export declare function msg(message: string, _options?: MsgOptions): string;
29
+ //# sourceMappingURL=localization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../src/localization.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,UAAU,GAAG;IACrB,wBAAwB;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CACf,CAAA;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC3C,MAAM,EAAE,MAAM,CAAC;gBACH,MAAM,EAAE,MAAM;CAI1B;AAED,wBAAgB,eAAe,IAAI,MAAM,CAMxC;AAMD,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,GAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,QAEhF;AAED,wBAAgB,SAAS,WAExB;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,WAEzC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAkBhD;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,CAkBlE"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.msg = exports.setLocale = exports.hasLocale = exports.getLocale = exports.registerLocale = exports.getSystemLocale = exports.LocaleChangeEvent = void 0;
4
+ class LocaleChangeEvent extends Event {
5
+ constructor(locale) {
6
+ super('localechange');
7
+ this.locale = locale;
8
+ }
9
+ }
10
+ exports.LocaleChangeEvent = LocaleChangeEvent;
11
+ function getSystemLocale() {
12
+ return typeof navigator !== 'undefined' ? (navigator.languages && navigator.languages.length
13
+ ? navigator.languages[0]
14
+ : navigator.language) : 'en';
15
+ }
16
+ exports.getSystemLocale = getSystemLocale;
17
+ const locales = new Map();
18
+ const localeSourceMap = new Map();
19
+ let currentLocale = getSystemLocale();
20
+ function registerLocale(locale, items) {
21
+ (Array.isArray(locale) ? locale : [locale]).forEach(l => locales.set(l, items));
22
+ }
23
+ exports.registerLocale = registerLocale;
24
+ function getLocale() {
25
+ return currentLocale;
26
+ }
27
+ exports.getLocale = getLocale;
28
+ function hasLocale(locale) {
29
+ return locales.has(locale);
30
+ }
31
+ exports.hasLocale = hasLocale;
32
+ function setLocale(locale) {
33
+ var _a;
34
+ if (!locales.has(locale)) {
35
+ let newLocale = currentLocale;
36
+ if (newLocale == null) {
37
+ if (locales.has('en'))
38
+ newLocale = 'en';
39
+ else if (locales.size > 0)
40
+ newLocale = locales.keys().next().value;
41
+ }
42
+ // log.getLogger().warn(`Locale ${locale} is not registered.${newLocale ? ` Switching to ${newLocale}.` : ''}`);
43
+ }
44
+ if (!localeSourceMap.has(locale))
45
+ localeSourceMap.set(locale, new Map());
46
+ const map = localeSourceMap.get(locale);
47
+ (_a = locales.get(locale)) === null || _a === void 0 ? void 0 : _a.forEach(i => map.set(i.source, i));
48
+ if (currentLocale !== locale) {
49
+ currentLocale = locale;
50
+ document.dispatchEvent(new LocaleChangeEvent(locale));
51
+ }
52
+ }
53
+ exports.setLocale = setLocale;
54
+ /**
55
+ * Translate a message to the current locale
56
+ * @param message source message
57
+ * @param _options reserved for future use
58
+ * @returns
59
+ */
60
+ function msg(message, _options) {
61
+ if (message == null || message === '')
62
+ return '';
63
+ const source = message.toLowerCase();
64
+ if (!localeSourceMap || !localeSourceMap.has(currentLocale) || !localeSourceMap.get(currentLocale).has(source)) {
65
+ return message;
66
+ }
67
+ let target = localeSourceMap.get(currentLocale).get(source).target;
68
+ if (target == null || target === '')
69
+ return '';
70
+ // Capitalize the first letter if the source message first letter is capitalized
71
+ if (message.length > 0 && message[0] === message[0].toUpperCase()) {
72
+ target = target[0].toUpperCase() + target.slice(1);
73
+ }
74
+ return target;
75
+ }
76
+ exports.msg = msg;
77
+ //# sourceMappingURL=localization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.js","sourceRoot":"","sources":["../src/localization.ts"],"names":[],"mappings":";;;AAeA,MAAa,iBAAkB,SAAQ,KAAK;IAE3C,YAAY,MAAc;QACzB,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAND,8CAMC;AAED,SAAgB,eAAe;IAC9B,OAAO,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,CACzC,SAAS,CAAC,SAAS,IAAI,S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E,CAAC;QACnE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAlBD,kBAkBC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@omegagrid/localize",
3
+ "version": "0.2.49",
4
+ "license": "UNLICENSED",
5
+ "description": "Localization",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "./dist/**/*"
10
+ ],
11
+ "keywords": [
12
+ "grid",
13
+ "datagrid",
14
+ "table",
15
+ "datatable",
16
+ "spreadsheet",
17
+ "component"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/cechi/omegagrid.git"
22
+ },
23
+ "bugs": "https://github.com/cechi/omegagrid/issues",
24
+ "author": {
25
+ "name": "Petr Čechura",
26
+ "email": "p.cechura@gmail.com",
27
+ "url": "https://cechura.eu"
28
+ },
29
+ "scripts": {
30
+ "watch": "tsc --watch",
31
+ "build": "yarn tsc",
32
+ "test": "jest --passWithNoTests",
33
+ "lint": "eslint **/src/**/*.ts",
34
+ "_prepack": "yarn build",
35
+ "_prepublish": "yarn test && yarn lint"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^20.11.5",
39
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
40
+ "@typescript-eslint/parser": "^7.16.0",
41
+ "eslint": "^8.56.0",
42
+ "jest": "^29.7.0",
43
+ "jest-environment-jsdom": "^29.7.0",
44
+ "ts-jest": "^29.1.1",
45
+ "ts-node": "^10.9.2",
46
+ "typescript": "5.3.2"
47
+ }
48
+ }