@tobio0310/i18n 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/error.d.ts +29 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +43 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Toby
|
|
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
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# i18n
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A small TypeScript library for easy internationalization
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error codes that can be raised by {@link I18n}
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ErrorCodes {
|
|
5
|
+
/**
|
|
6
|
+
* The default locale was missing the given key.
|
|
7
|
+
*
|
|
8
|
+
* If using TypeScript, the TypeScript compiler should refuse to compile the code if this error can be raised.
|
|
9
|
+
* Should it ever be raised, and you're using TypeScript. Please report it back to the authors.
|
|
10
|
+
*/
|
|
11
|
+
MissingI18nCodesInDefaultLocale = 0
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An error class raised by {@link I18n}, should any error occur.
|
|
15
|
+
*
|
|
16
|
+
* @see ErrorCodes
|
|
17
|
+
*/
|
|
18
|
+
export declare class I18nError extends Error {
|
|
19
|
+
code: ErrorCodes;
|
|
20
|
+
constructor(code: ErrorCodes, message: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether the given `err` is a {@link I18nError}.
|
|
24
|
+
*
|
|
25
|
+
* @param err the error to check
|
|
26
|
+
* @returns `true` if `err` is a {@link I18nError}, `false` otherwise
|
|
27
|
+
*/
|
|
28
|
+
export declare function isI18nError(err: unknown): err is I18nError;
|
|
29
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,oBAAY,UAAU;IAClB;;;;;OAKG;IACH,+BAA+B,IAAI;CACtC;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IACzB,IAAI,EAAE,UAAU,CAAC;IAExB,YAAmB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAQnD;CACJ;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAO1D"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const ERROR_SYMBOL = Symbol.for("@tobio0310/i18n.ERROR_SYMBOL");
|
|
2
|
+
/**
|
|
3
|
+
* The error codes that can be raised by {@link I18n}
|
|
4
|
+
*/
|
|
5
|
+
export var ErrorCodes;
|
|
6
|
+
(function (ErrorCodes) {
|
|
7
|
+
/**
|
|
8
|
+
* The default locale was missing the given key.
|
|
9
|
+
*
|
|
10
|
+
* If using TypeScript, the TypeScript compiler should refuse to compile the code if this error can be raised.
|
|
11
|
+
* Should it ever be raised, and you're using TypeScript. Please report it back to the authors.
|
|
12
|
+
*/
|
|
13
|
+
ErrorCodes[ErrorCodes["MissingI18nCodesInDefaultLocale"] = 0] = "MissingI18nCodesInDefaultLocale";
|
|
14
|
+
})(ErrorCodes || (ErrorCodes = {}));
|
|
15
|
+
/**
|
|
16
|
+
* An error class raised by {@link I18n}, should any error occur.
|
|
17
|
+
*
|
|
18
|
+
* @see ErrorCodes
|
|
19
|
+
*/
|
|
20
|
+
export class I18nError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(code, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
Object.defineProperty(this, ERROR_SYMBOL, {
|
|
26
|
+
value: true,
|
|
27
|
+
enumerable: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether the given `err` is a {@link I18nError}.
|
|
33
|
+
*
|
|
34
|
+
* @param err the error to check
|
|
35
|
+
* @returns `true` if `err` is a {@link I18nError}, `false` otherwise
|
|
36
|
+
*/
|
|
37
|
+
export function isI18nError(err) {
|
|
38
|
+
return (err != null && // not null or undefined
|
|
39
|
+
typeof err === "object" &&
|
|
40
|
+
ERROR_SYMBOL in err &&
|
|
41
|
+
err[ERROR_SYMBOL] === true);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IAClB;;;;;OAKG;IACH,iGAAmC,CAAA;AACvC,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB;AAED;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAa;IAExB,YAAmB,IAAgB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE;YACtC,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;SACpB,CAAC,CAAC;IACP,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACpC,OAAO,CACH,GAAG,IAAI,IAAI,IAAI,wBAAwB;QACvC,OAAO,GAAG,KAAK,QAAQ;QACvB,YAAY,IAAI,GAAG;QACnB,GAAG,CAAC,YAAY,CAAC,KAAK,IAAI,CAC7B,CAAC;AACN,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type ExpandKey, type ValidNode, type ResolvePath } from "@tobio0310/json-walker";
|
|
2
|
+
import { I18nError, ErrorCodes, isI18nError } from "./error.js";
|
|
3
|
+
export { I18nError, ErrorCodes, isI18nError };
|
|
4
|
+
/**
|
|
5
|
+
* The default locale leaf available via {@link I18n.withDefaultLeaves}
|
|
6
|
+
*/
|
|
7
|
+
export type DefaultLocaleLeaf = string | number | ((...args: any[]) => any);
|
|
8
|
+
/**
|
|
9
|
+
* The type a `IsLeaf` function must satisfy to be used in {@link I18n.constructor}
|
|
10
|
+
*/
|
|
11
|
+
export type IsLeafFunction<Leaf> = (value: unknown) => value is Leaf;
|
|
12
|
+
/**
|
|
13
|
+
* A class that wraps around locale nodes, to provide internationalization (i18n).
|
|
14
|
+
*
|
|
15
|
+
* It uses {@link tryWalk} from {@link https://www.npmjs.com/package/@tobio0310/json-walker json-walker},
|
|
16
|
+
* to walk through a json object.
|
|
17
|
+
* This package allows using wildcards on intermediary nodes towards the leaf,
|
|
18
|
+
* like getting all titles of pages through `page.*.title` (which returns a `string[]`, with TypeScript support!)
|
|
19
|
+
*
|
|
20
|
+
* It is expected that the locales are static, and never change once this has been instantiated.
|
|
21
|
+
* Dynamically creating new {@link I18n} instances may overload your language server, please be aware of that.
|
|
22
|
+
*
|
|
23
|
+
* ## Leaf Notes
|
|
24
|
+
*
|
|
25
|
+
* Any value is *technically* allowed to be a leaf. However, please be aware that allowing objects
|
|
26
|
+
* to be leafs may cause the types to fail computing. Selecting specialized objects, like `React.ReactElement`
|
|
27
|
+
* is unlikely to cause failed type computing, however
|
|
28
|
+
*/
|
|
29
|
+
export declare class I18n<Leaf, LocaleNodes extends Record<string, ValidNode<Leaf>>, DefaultLocale extends keyof LocaleNodes> {
|
|
30
|
+
private localeNodes;
|
|
31
|
+
private isLeaf;
|
|
32
|
+
private _defaultLocale;
|
|
33
|
+
/**
|
|
34
|
+
* Create a {@link I18n} object.
|
|
35
|
+
*
|
|
36
|
+
* @param localeNodes the available locales, and their nodes
|
|
37
|
+
* @param defaultLocale the default locale to use in {@link I18n#getText}
|
|
38
|
+
* @param isLeaf a function that determines whether a node is a leaf or not.
|
|
39
|
+
* The given function is forwarded to {@link tryWalk}, see it for more info.
|
|
40
|
+
*/
|
|
41
|
+
constructor(localeNodes: LocaleNodes, defaultLocale: DefaultLocale, isLeaf: IsLeafFunction<Leaf>);
|
|
42
|
+
/**
|
|
43
|
+
* Creates an {@link I18n} instance using the standard {@link DefaultLocaleLeaf} types.
|
|
44
|
+
*
|
|
45
|
+
* @param locales the available locales
|
|
46
|
+
* @param defaultLocale the default locale chosen
|
|
47
|
+
* @returns the created {@link I18n} instance
|
|
48
|
+
*/
|
|
49
|
+
static withDefaultLeaves<LocaleNodes extends Record<string, ValidNode<DefaultLocaleLeaf>>, DefaultLocale extends keyof LocaleNodes>(locales: LocaleNodes, defaultLocale: DefaultLocale): I18n<DefaultLocaleLeaf, LocaleNodes, DefaultLocale>;
|
|
50
|
+
/**
|
|
51
|
+
* The locales available in this {@link I18n}.
|
|
52
|
+
*/
|
|
53
|
+
get locales(): (keyof LocaleNodes)[];
|
|
54
|
+
/**
|
|
55
|
+
* The default locale selected for this {@link I18n}.
|
|
56
|
+
*/
|
|
57
|
+
get defaultLocale(): DefaultLocale;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the i18n text given by `code` in the requested `locale`,
|
|
60
|
+
* or null if locale doesn't have said code.
|
|
61
|
+
*
|
|
62
|
+
* @param code the json-walker code to look up in requested locale
|
|
63
|
+
* @param locale the locale you want the code in
|
|
64
|
+
* @param required set to `true` if the text must be returned.
|
|
65
|
+
* If the request locale doesn't have a valid walk,
|
|
66
|
+
* it will then look up the code in the default locale,
|
|
67
|
+
* which is expected to always have all valid codes.
|
|
68
|
+
* @throws I18nError if an error was detected, including broken invariants
|
|
69
|
+
*/
|
|
70
|
+
getText<Code extends ExpandKey<Leaf, LocaleNodes[DefaultLocale]>>(code: Code, locale: keyof LocaleNodes, required?: boolean): ResolvePath<Leaf, LocaleNodes[DefaultLocale], Code> | null;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the i18n text given by `code` in the requested `locale`,
|
|
73
|
+
* or in the default locale if request locale doesn't have said code.
|
|
74
|
+
*
|
|
75
|
+
* Default locale must always have the given code, so that this look-up never fails.
|
|
76
|
+
* Should it fail, an {@link I18nError} will be thrown.
|
|
77
|
+
*
|
|
78
|
+
* @param code the json-walker code to look up in requested locale
|
|
79
|
+
* @param locale the locale you want the code in
|
|
80
|
+
* @throws I18nError if an error was detected, including broken invariants
|
|
81
|
+
*/
|
|
82
|
+
getText<Code extends ExpandKey<Leaf, LocaleNodes[DefaultLocale]>>(code: Code, locale: keyof LocaleNodes, required: true): ResolvePath<Leaf, LocaleNodes[DefaultLocale], Code>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,SAAS,EAEd,KAAK,SAAS,EACd,KAAK,WAAW,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,IAAI,CACb,IAAI,EACJ,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,EACnD,aAAa,SAAS,MAAM,WAAW;IAYnC,OAAO,CAAC,WAAW;IAEnB,OAAO,CAAC,MAAM;IAZlB,OAAO,CAAC,cAAc,CAAgB;IACtC;;;;;;;OAOG;IACH,YACY,WAAW,EAAE,WAAW,EAChC,aAAa,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,EAGvC;IAED;;;;;;OAMG;IACH,OAAc,iBAAiB,CAC3B,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC,EAChE,aAAa,SAAS,MAAM,WAAW,EAEvC,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,aAAa,GAC7B,IAAI,CAAC,iBAAiB,EAAE,WAAW,EAAE,aAAa,CAAC,CAYrD;IAED;;OAEG;IACH,IAAW,OAAO,IAAI,CAAC,MAAM,WAAW,CAAC,EAAE,CAE1C;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,aAAa,CAExC;IAED;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,IAAI,SAAS,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,EACnE,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,WAAW,EACzB,QAAQ,CAAC,EAAE,OAAO,GACnB,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9D;;;;;;;;;;OAUG;IACI,OAAO,CAAC,IAAI,SAAS,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,EACnE,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,WAAW,EACzB,QAAQ,EAAE,IAAI,GACf,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,CAAC;CAgC1D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { tryWalk, } from "@tobio0310/json-walker";
|
|
2
|
+
import { I18nError, ErrorCodes, isI18nError } from "./error.js";
|
|
3
|
+
export { I18nError, ErrorCodes, isI18nError };
|
|
4
|
+
/**
|
|
5
|
+
* A class that wraps around locale nodes, to provide internationalization (i18n).
|
|
6
|
+
*
|
|
7
|
+
* It uses {@link tryWalk} from {@link https://www.npmjs.com/package/@tobio0310/json-walker json-walker},
|
|
8
|
+
* to walk through a json object.
|
|
9
|
+
* This package allows using wildcards on intermediary nodes towards the leaf,
|
|
10
|
+
* like getting all titles of pages through `page.*.title` (which returns a `string[]`, with TypeScript support!)
|
|
11
|
+
*
|
|
12
|
+
* It is expected that the locales are static, and never change once this has been instantiated.
|
|
13
|
+
* Dynamically creating new {@link I18n} instances may overload your language server, please be aware of that.
|
|
14
|
+
*
|
|
15
|
+
* ## Leaf Notes
|
|
16
|
+
*
|
|
17
|
+
* Any value is *technically* allowed to be a leaf. However, please be aware that allowing objects
|
|
18
|
+
* to be leafs may cause the types to fail computing. Selecting specialized objects, like `React.ReactElement`
|
|
19
|
+
* is unlikely to cause failed type computing, however
|
|
20
|
+
*/
|
|
21
|
+
export class I18n {
|
|
22
|
+
localeNodes;
|
|
23
|
+
isLeaf;
|
|
24
|
+
_defaultLocale;
|
|
25
|
+
/**
|
|
26
|
+
* Create a {@link I18n} object.
|
|
27
|
+
*
|
|
28
|
+
* @param localeNodes the available locales, and their nodes
|
|
29
|
+
* @param defaultLocale the default locale to use in {@link I18n#getText}
|
|
30
|
+
* @param isLeaf a function that determines whether a node is a leaf or not.
|
|
31
|
+
* The given function is forwarded to {@link tryWalk}, see it for more info.
|
|
32
|
+
*/
|
|
33
|
+
constructor(localeNodes, defaultLocale, isLeaf) {
|
|
34
|
+
this.localeNodes = localeNodes;
|
|
35
|
+
this.isLeaf = isLeaf;
|
|
36
|
+
this._defaultLocale = defaultLocale;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates an {@link I18n} instance using the standard {@link DefaultLocaleLeaf} types.
|
|
40
|
+
*
|
|
41
|
+
* @param locales the available locales
|
|
42
|
+
* @param defaultLocale the default locale chosen
|
|
43
|
+
* @returns the created {@link I18n} instance
|
|
44
|
+
*/
|
|
45
|
+
static withDefaultLeaves(locales, defaultLocale) {
|
|
46
|
+
return new I18n(locales, defaultLocale, (value) => {
|
|
47
|
+
return (typeof value === "string" ||
|
|
48
|
+
typeof value === "number" ||
|
|
49
|
+
typeof value === "function");
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The locales available in this {@link I18n}.
|
|
54
|
+
*/
|
|
55
|
+
get locales() {
|
|
56
|
+
return Object.keys(this.localeNodes);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The default locale selected for this {@link I18n}.
|
|
60
|
+
*/
|
|
61
|
+
get defaultLocale() {
|
|
62
|
+
return this._defaultLocale;
|
|
63
|
+
}
|
|
64
|
+
getText(code, locale, required) {
|
|
65
|
+
const preferredLocaleText = tryWalk(code, this.localeNodes[locale], this.isLeaf);
|
|
66
|
+
if (required === false || preferredLocaleText !== null) {
|
|
67
|
+
return preferredLocaleText;
|
|
68
|
+
}
|
|
69
|
+
const defaultLocaleText = tryWalk(code, this.localeNodes[this.defaultLocale], this.isLeaf);
|
|
70
|
+
if (!defaultLocaleText) {
|
|
71
|
+
throw new I18nError(ErrorCodes.MissingI18nCodesInDefaultLocale, `missing i18n code ${code} for default locale: ${this.defaultLocale.toString()}`);
|
|
72
|
+
}
|
|
73
|
+
return defaultLocaleText;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,GAGV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAY9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,IAAI;IAeD,WAAW;IAEX,MAAM;IAZV,cAAc,CAAgB;IACtC;;;;;;;OAOG;IACH,YACY,WAAwB,EAChC,aAA4B,EACpB,MAA4B;2BAF5B,WAAW;sBAEX,MAAM;QAEd,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,iBAAiB,CAI3B,OAAoB,EACpB,aAA4B;QAE5B,OAAO,IAAI,IAAI,CACX,OAAO,EACP,aAAa,EACb,CAAC,KAAc,EAA8B,EAAE;YAC3C,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;gBACzB,OAAO,KAAK,KAAK,QAAQ;gBACzB,OAAO,KAAK,KAAK,UAAU,CAC9B,CAAC;QACN,CAAC,CACJ,CAAC;IACN,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAmCM,OAAO,CACV,IAAU,EACV,MAAyB,EACzB,QAAkB;QAElB,MAAM,mBAAmB,GAAG,OAAO,CAC/B,IAAW,EACX,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EACxB,IAAI,CAAC,MAAM,CACP,CAAC;QAET,IAAI,QAAQ,KAAK,KAAK,IAAI,mBAAmB,KAAK,IAAI,EAAE,CAAC;YACrD,OAAO,mBAIC,CAAC;QACb,CAAC;QACD,MAAM,iBAAiB,GAAG,OAAO,CAC7B,IAAI,EACJ,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EACpC,IAAI,CAAC,MAAM,CACgD,CAAC;QAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACrB,MAAM,IAAI,SAAS,CACf,UAAU,CAAC,+BAA+B,EAC1C,qBAAqB,IAAI,wBAAwB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,CACnF,CAAC;QACN,CAAC;QACD,OAAO,iBAAkB,CAAC;IAC9B,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
"name": "@tobio0310/i18n",
|
|
3
|
+
"author": {
|
|
4
|
+
"name": "Toby",
|
|
5
|
+
"url": "https://cv.tobysch.eu"
|
|
6
|
+
},
|
|
7
|
+
"version": "1.0.1",
|
|
8
|
+
"description": "A small TypeScript library for easy internationalization",
|
|
9
|
+
"homepage": "https://forgejo.tobysch.eu/tobiO0310/i18n#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://forgejo.tobysch.eu/tobiO0310/i18n/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://forgejo.tobysch.eu/tobiO0310/i18n.git"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"directories": {
|
|
22
|
+
"test": "tests"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.app.json",
|
|
36
|
+
"test": "vitest",
|
|
37
|
+
"prepare": "npm run build",
|
|
38
|
+
"postversion": "git push origin main && git push --tags"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@tobio0310/json-walker": "^1.0.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^7.0.2",
|
|
45
|
+
"vitest": "=5.1.2"
|
|
46
|
+
},
|
|
47
|
+
"allowScripts": {
|
|
48
|
+
"fsevents@2.3.3": true
|
|
49
|
+
}
|
|
50
|
+
}
|