@rimelight/i18n 0.0.9 → 0.0.10
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/hono.d.mts +2 -3
- package/dist/hono.mjs +2 -2
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +3 -3
- package/dist/{plugin-nQl4lZKv.mjs → plugin-jh44sjC0.mjs} +2 -2
- package/dist/plugin.mjs +1 -1
- package/dist/{runtime-Civir_tv.mjs → runtime-LitYNVlO.mjs} +3 -3
- package/dist/runtime.mjs +1 -1
- package/dist/{src-D09inETW.mjs → src-DDBWfigm.mjs} +1 -1
- package/dist/utils.d.mts +5 -6
- package/package.json +3 -3
package/dist/hono.d.mts
CHANGED
|
@@ -3,6 +3,5 @@
|
|
|
3
3
|
* Hono middleware for Rimelight i18n. Handles locale routing, redirection, currentLocale store
|
|
4
4
|
* updates, and Cloudflare KV binding setup.
|
|
5
5
|
*/
|
|
6
|
-
declare function i18n(): (c: any, next: any) => Promise<any>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { i18n };
|
|
6
|
+
export declare function i18n(): (c: any, next: any) => Promise<any>;
|
|
7
|
+
//#endregion
|
package/dist/hono.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as currentLocale } from "./runtime-
|
|
2
|
-
import { d as setKVBinding } from "./src-
|
|
1
|
+
import { n as currentLocale } from "./runtime-LitYNVlO.mjs";
|
|
2
|
+
import { d as setKVBinding } from "./src-DDBWfigm.mjs";
|
|
3
3
|
import { env } from "cloudflare:workers";
|
|
4
4
|
import { defaultLocale, locales, prefixDefaultLocale } from "virtual:rimelight-i18n-config";
|
|
5
5
|
//#region src/hono.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -10,21 +10,21 @@ declare let prefixDefaultLocale: boolean;
|
|
|
10
10
|
* Translates a single string key using dot-notation (e.g. `t("page_home.section_hero_title")`).
|
|
11
11
|
* When augmented via CustomTranslations, keys are strictly type-checked and autocompleted.
|
|
12
12
|
*/
|
|
13
|
-
declare function t<K extends string = TranslationKey>(key: K | TranslationKey, params?: Record<string, any>): string;
|
|
14
|
-
declare function getLocale(): string;
|
|
13
|
+
export declare function t<K extends string = TranslationKey>(key: K | TranslationKey, params?: Record<string, any>): string;
|
|
14
|
+
export declare function getLocale(): string;
|
|
15
15
|
/**
|
|
16
16
|
* Returns a standard BCP 47 / RFC 5646 language tag suitable for HTML `<html lang="...">`. Maps
|
|
17
17
|
* 2-letter codes like 'en' to 'en-US', 'pt' to 'pt-BR', 'es' to 'es-ES', etc.
|
|
18
18
|
*/
|
|
19
|
-
declare function getHtmlLang(): string;
|
|
19
|
+
export declare function getHtmlLang(): string;
|
|
20
20
|
/**
|
|
21
21
|
* Returns an OpenGraph-compliant locale tag (e.g. 'en_US', 'pt_BR', 'es_ES').
|
|
22
22
|
*/
|
|
23
|
-
declare function getOgLocale(): string;
|
|
24
|
-
declare function getRelativeLocaleUrl(path: string): string;
|
|
25
|
-
declare function getRelativeLocaleUrl(locale: string, path: string): string;
|
|
26
|
-
declare function getRelativeLocaleUrlList(path?: string): string[];
|
|
27
|
-
interface LanguageAlternate {
|
|
23
|
+
export declare function getOgLocale(): string;
|
|
24
|
+
export declare function getRelativeLocaleUrl(path: string): string;
|
|
25
|
+
export declare function getRelativeLocaleUrl(locale: string, path: string): string;
|
|
26
|
+
export declare function getRelativeLocaleUrlList(path?: string): string[];
|
|
27
|
+
export interface LanguageAlternate {
|
|
28
28
|
hreflang: string;
|
|
29
29
|
href: string;
|
|
30
30
|
}
|
|
@@ -32,8 +32,8 @@ interface LanguageAlternate {
|
|
|
32
32
|
* Generates an array of hreflang alternates for SEO tags (<link rel="alternate" hreflang="...">).
|
|
33
33
|
* Automatically includes all supported locales and 'x-default'.
|
|
34
34
|
*/
|
|
35
|
-
declare function getLanguageAlternates(pathname: string, siteUrl?: string): LanguageAlternate[];
|
|
36
|
-
declare function setKVBinding(kv: KVNamespaceBinding): void;
|
|
37
|
-
declare function createTranslationLoader(translations: Record<string, ComponentsJSON>): TranslationLoader;
|
|
35
|
+
export declare function getLanguageAlternates(pathname: string, siteUrl?: string): LanguageAlternate[];
|
|
36
|
+
export declare function setKVBinding(kv: KVNamespaceBinding): void;
|
|
37
|
+
export declare function createTranslationLoader(translations: Record<string, ComponentsJSON>): TranslationLoader;
|
|
38
38
|
//#endregion
|
|
39
|
-
export { type CustomTranslations,
|
|
39
|
+
export { type CustomTranslations, type NestedTranslationKeys, type RimelightI18nOptions, type RimelightI18nPlugins, type TranslationKey, clearCache, currentLocale, defaultLocale, getFormatterInstance, getI18nInstance, getPluralCategory, i18n, i18n as rimelightI18n, initializeI18n, locales, prefixDefaultLocale, useFormat, useI18n, useI18nAsync };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getPluralCategory, c as useFormat, i as getI18nInstance, l as useI18n, n as currentLocale, o as initializeI18n, r as getFormatterInstance, t as clearCache, u as useI18nAsync } from "./runtime-
|
|
2
|
-
import { t as i18n } from "./plugin-
|
|
3
|
-
import { a as getLocale, c as getRelativeLocaleUrlList, d as setKVBinding, f as t, i as getLanguageAlternates, l as locales, n as defaultLocale, o as getOgLocale, r as getHtmlLang, s as getRelativeLocaleUrl, t as createTranslationLoader, u as prefixDefaultLocale } from "./src-
|
|
1
|
+
import { a as getPluralCategory, c as useFormat, i as getI18nInstance, l as useI18n, n as currentLocale, o as initializeI18n, r as getFormatterInstance, t as clearCache, u as useI18nAsync } from "./runtime-LitYNVlO.mjs";
|
|
2
|
+
import { t as i18n } from "./plugin-jh44sjC0.mjs";
|
|
3
|
+
import { a as getLocale, c as getRelativeLocaleUrlList, d as setKVBinding, f as t, i as getLanguageAlternates, l as locales, n as defaultLocale, o as getOgLocale, r as getHtmlLang, s as getRelativeLocaleUrl, t as createTranslationLoader, u as prefixDefaultLocale } from "./src-DDBWfigm.mjs";
|
|
4
4
|
export { clearCache, createTranslationLoader, currentLocale, defaultLocale, getFormatterInstance, getHtmlLang, getI18nInstance, getLanguageAlternates, getLocale, getOgLocale, getPluralCategory, getRelativeLocaleUrl, getRelativeLocaleUrlList, i18n, i18n as rimelightI18n, initializeI18n, locales, prefixDefaultLocale, setKVBinding, t, useFormat, useI18n, useI18nAsync };
|
|
@@ -35,12 +35,12 @@ function i18n(options) {
|
|
|
35
35
|
key: `locale:${locale}:${component}`,
|
|
36
36
|
value: JSON.stringify(componentData)
|
|
37
37
|
});
|
|
38
|
-
const outDir = process.env
|
|
38
|
+
const outDir = process.env["WRANGLER_OUT_DIR"] ?? "dist";
|
|
39
39
|
const seedFile = path.join(outDir, "_translations-seed.json");
|
|
40
40
|
try {
|
|
41
41
|
fs.mkdirSync(path.dirname(seedFile), { recursive: true });
|
|
42
42
|
fs.writeFileSync(seedFile, JSON.stringify(seedData, null, 2));
|
|
43
|
-
if (process.env
|
|
43
|
+
if (process.env["WRANGLER_SEED_KV"] === "true" || process.env["CI"] === "true") {
|
|
44
44
|
const { execSync } = await import("node:child_process");
|
|
45
45
|
execSync(`npx wrangler kv:bulk put --binding "${kvBinding}" "${seedFile}"`, {
|
|
46
46
|
stdio: "pipe",
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as i18n } from "./plugin-
|
|
1
|
+
import { t as i18n } from "./plugin-jh44sjC0.mjs";
|
|
2
2
|
export { i18n, i18n as rimelightI18n };
|
|
@@ -153,9 +153,9 @@ function t(key, params) {
|
|
|
153
153
|
const keyName = key.slice(dotIndex + 1);
|
|
154
154
|
const activeLocale = currentLocale.get() || baseLocaleDefault;
|
|
155
155
|
let value = (getCachedComponent(activeLocale, componentName) ?? getCachedComponent(baseLocaleDefault, componentName) ?? {})[keyName] ?? key;
|
|
156
|
-
if (params && typeof params
|
|
157
|
-
const pluralCategory = getPluralCategory(params
|
|
158
|
-
value = value[pluralCategory] ?? value
|
|
156
|
+
if (params && typeof params["count"] === "number" && typeof value === "object" && value !== null) {
|
|
157
|
+
const pluralCategory = getPluralCategory(params["count"], activeLocale);
|
|
158
|
+
value = value[pluralCategory] ?? value["other"] ?? key;
|
|
159
159
|
}
|
|
160
160
|
if (typeof value === "function") return value(params);
|
|
161
161
|
if (params && typeof value === "string") return value.replace(/\{(\w+)\}/g, (_, k) => String(params[k] ?? `{${k}}`));
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getPluralCategory, c as useFormat, i as getI18nInstance, l as useI18n, n as currentLocale, o as initializeI18n, r as getFormatterInstance, s as t, t as clearCache, u as useI18nAsync } from "./runtime-
|
|
1
|
+
import { a as getPluralCategory, c as useFormat, i as getI18nInstance, l as useI18n, n as currentLocale, o as initializeI18n, r as getFormatterInstance, s as t, t as clearCache, u as useI18nAsync } from "./runtime-LitYNVlO.mjs";
|
|
2
2
|
export { clearCache, currentLocale, getFormatterInstance, getI18nInstance, getPluralCategory, initializeI18n, t, useFormat, useI18n, useI18nAsync };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { r as FlattenedTranslations, t as ComponentsJSON } from "./types-BKUPwH-e.mjs";
|
|
2
2
|
//#region src/utils.d.ts
|
|
3
|
-
declare function flatten(obj: ComponentsJSON): FlattenedTranslations;
|
|
4
|
-
declare function unflatten(flat: FlattenedTranslations): ComponentsJSON;
|
|
5
|
-
declare function extractKeys(source: ComponentsJSON): string[];
|
|
3
|
+
export declare function flatten(obj: ComponentsJSON): FlattenedTranslations;
|
|
4
|
+
export declare function unflatten(flat: FlattenedTranslations): ComponentsJSON;
|
|
5
|
+
export declare function extractKeys(source: ComponentsJSON): string[];
|
|
6
6
|
/**
|
|
7
7
|
* Compares a target translation dictionary against a base/source translation dictionary, returning
|
|
8
8
|
* any missing component keys.
|
|
9
9
|
*/
|
|
10
|
-
declare function findMissingKeys(base: Record<string, Record<string, any>>, target: Record<string, Record<string, any>>): string[];
|
|
11
|
-
//#endregion
|
|
12
|
-
export { extractKeys, findMissingKeys, flatten, unflatten };
|
|
10
|
+
export declare function findMissingKeys(base: Record<string, Record<string, any>>, target: Record<string, Record<string, any>>): string[];
|
|
11
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimelight/i18n",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Rimelight Entertainment's Internationalization Package",
|
|
6
6
|
"homepage": "https://rimelight.com/docs",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"nanostores": "1.5.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rimelight/config": "0.0.
|
|
56
|
+
"@rimelight/config": "0.0.6",
|
|
57
57
|
"typescript": "6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=26.
|
|
60
|
+
"node": ">=26.8.2"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "vp pack",
|