intl-template 1.0.0 → 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/dist/intl.d.ts +37 -0
- package/package.json +4 -3
package/dist/intl.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a template string and extracts the template parts and order of slots.
|
|
3
|
+
* @param {string} templateString - The template string to parse.
|
|
4
|
+
* @returns {{ template: string[], order: number[] }}
|
|
5
|
+
*/
|
|
6
|
+
export function parseTemplate(templateString: string): {
|
|
7
|
+
template: string[];
|
|
8
|
+
order: number[];
|
|
9
|
+
};
|
|
10
|
+
export class Runes extends Array<any> {
|
|
11
|
+
constructor(arrayLength?: number);
|
|
12
|
+
constructor(arrayLength: number);
|
|
13
|
+
constructor(...items: any[]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a Translation object that handles string translation based on locale and templates.
|
|
17
|
+
*/
|
|
18
|
+
export class Translation {
|
|
19
|
+
/** @type {"" | "react"} */
|
|
20
|
+
mode: "" | "react";
|
|
21
|
+
set templates(value: Proxy);
|
|
22
|
+
get templates(): Proxy;
|
|
23
|
+
/**
|
|
24
|
+
* Translates a string based on the provided locale and strings.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} locale - The locale to use for translation.
|
|
27
|
+
* @param {TemplateStringsArray | string} strings - The string or array of strings to be translated.
|
|
28
|
+
* @param {...any} parts - The dynamic parts to be inserted into the translated string.
|
|
29
|
+
* @returns {Runes} - The translated string with dynamic parts inserted.
|
|
30
|
+
* @throws {Error} - If the length of the template parts does not match the length of the template.
|
|
31
|
+
*/
|
|
32
|
+
translate: (locale: string, strings: TemplateStringsArray | string, ...parts: any[]) => Runes;
|
|
33
|
+
#private;
|
|
34
|
+
}
|
|
35
|
+
export default translation;
|
|
36
|
+
export const l10n: any;
|
|
37
|
+
declare const translation: Translation;
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intl-template",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "l10n tagged template literals",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/intl.js",
|
|
7
7
|
"module": "src/intl.js",
|
|
8
8
|
"repository": "github:performonkey/intl-template",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "bun build src/intl.js --outdir=dist --format=cjs"
|
|
10
|
+
"build": "bun build src/intl.js --outdir=dist --format=cjs",
|
|
11
|
+
"postbuild": "tsc --emitDeclarationOnly --allowJs -d --outDir dist ./src/intl.js"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [
|
|
13
14
|
"i18n",
|
|
@@ -16,4 +17,4 @@
|
|
|
16
17
|
],
|
|
17
18
|
"author": "p10y",
|
|
18
19
|
"license": "ISC"
|
|
19
|
-
}
|
|
20
|
+
}
|