@pocket-trash/localizations 0.0.9 → 0.1.0
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/README.md +0 -15
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -8
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -153,20 +153,6 @@ const save = translations['action.save'];
|
|
|
153
153
|
Returned catalogs are complete. If a non-English locale omits a translation,
|
|
154
154
|
or has a blank string, that key falls back to the `en-US` value.
|
|
155
155
|
|
|
156
|
-
## Clerk Localizations
|
|
157
|
-
|
|
158
|
-
Use `getClerkLocalization()` when configuring Clerk UI components.
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
import { getClerkLocalization, resolveLocale } from '@pocket-trash/localizations';
|
|
162
|
-
|
|
163
|
-
const locale = resolveLocale('es-MX');
|
|
164
|
-
const localization = getClerkLocalization(locale);
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
English returns `undefined`, so Clerk uses its default English strings. Spanish
|
|
168
|
-
returns Clerk's `esMX` localization.
|
|
169
|
-
|
|
170
156
|
## Adding Translations
|
|
171
157
|
|
|
172
158
|
Source locale files use nested objects:
|
|
@@ -214,7 +200,6 @@ That command:
|
|
|
214
200
|
2. Copies the nested `en-US` shape with every value set to `''`.
|
|
215
201
|
3. Adds the locale to `SupportedLocale`, `SUPPORTED_LOCALES`, `localizations`,
|
|
216
202
|
and `translations`.
|
|
217
|
-
4. Adds a Clerk localization mapping if `@clerk/localizations` exports one.
|
|
218
203
|
|
|
219
204
|
Sync missing keys into existing non-English locales:
|
|
220
205
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { esMX as clerkEsMX } from "@clerk/localizations";
|
|
2
1
|
import type { TranslationKey, Translations } from "./types/localization.js";
|
|
3
2
|
export { enUS } from "./localizations/en-US.js";
|
|
4
3
|
export { esMX } from "./localizations/es-MX.js";
|
|
@@ -7,7 +6,6 @@ export type SupportedLocale = "en-US" | "es-MX";
|
|
|
7
6
|
export type MessageKey = TranslationKey;
|
|
8
7
|
export type Messages = Translations;
|
|
9
8
|
export type LocalePreference = string | readonly string[] | null | undefined;
|
|
10
|
-
export type ClerkLocalizationResource = typeof clerkEsMX;
|
|
11
9
|
export declare const DEFAULT_LOCALE = "en-US";
|
|
12
10
|
export declare const SUPPORTED_LOCALES: readonly ["en-US", "es-MX"];
|
|
13
11
|
export declare const localizations: Readonly<{
|
|
@@ -52,11 +50,9 @@ export declare const messages: Readonly<{
|
|
|
52
50
|
"es-MX": Readonly<Readonly<Record<TranslationKey, string>>>;
|
|
53
51
|
}>;
|
|
54
52
|
export declare const messageKeys: readonly TranslationKey[];
|
|
55
|
-
export declare const clerkLocalizations: Readonly<Record<SupportedLocale, ClerkLocalizationResource | undefined>>;
|
|
56
53
|
export declare function resolveLocale(...preferences: readonly LocalePreference[]): SupportedLocale;
|
|
57
54
|
export declare function getTranslations(locale?: SupportedLocale | null): Translations;
|
|
58
55
|
export declare const getMessages: typeof getTranslations;
|
|
59
|
-
export declare function getClerkLocalization(locale?: SupportedLocale | null): ClerkLocalizationResource | undefined;
|
|
60
56
|
export declare function formatTranslation(key: TranslationKey, values?: Readonly<Record<string, unknown>>, locale?: SupportedLocale | null): string;
|
|
61
57
|
export declare const formatMessage: typeof formatTranslation;
|
|
62
58
|
export declare function assertCompleteCatalogs(): true;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { esMX as clerkEsMX } from "@clerk/localizations";
|
|
2
1
|
import { enUS } from "./localizations/en-US.js";
|
|
3
2
|
import { esMX } from "./localizations/es-MX.js";
|
|
4
3
|
export { enUS } from "./localizations/en-US.js";
|
|
@@ -23,10 +22,6 @@ export const translations = Object.freeze({
|
|
|
23
22
|
});
|
|
24
23
|
export const messages = translations;
|
|
25
24
|
export const messageKeys = translationKeys;
|
|
26
|
-
export const clerkLocalizations = Object.freeze({
|
|
27
|
-
"en-US": undefined,
|
|
28
|
-
"es-MX": clerkEsMX,
|
|
29
|
-
});
|
|
30
25
|
export function resolveLocale(...preferences) {
|
|
31
26
|
for (const preference of preferences.flat()) {
|
|
32
27
|
for (const tag of parseLocalePreference(preference)) {
|
|
@@ -41,9 +36,6 @@ export function getTranslations(locale) {
|
|
|
41
36
|
return translations[resolveLocale(locale)];
|
|
42
37
|
}
|
|
43
38
|
export const getMessages = getTranslations;
|
|
44
|
-
export function getClerkLocalization(locale) {
|
|
45
|
-
return clerkLocalizations[resolveLocale(locale)];
|
|
46
|
-
}
|
|
47
39
|
export function formatTranslation(key, values = {}, locale = DEFAULT_LOCALE) {
|
|
48
40
|
const template = getTranslations(locale)[key] ?? translations[DEFAULT_LOCALE][key];
|
|
49
41
|
if (!template)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocket-trash/localizations",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Shared localization utilities and message catalogs for Pocket Trash.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"typescript": "^5.9.2"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@clerk/localizations": "^4.14.2",
|
|
47
46
|
"lts": "^2.0.0"
|
|
48
47
|
},
|
|
49
48
|
"scripts": {
|
|
@@ -56,7 +55,7 @@
|
|
|
56
55
|
"lint": "biome ci .",
|
|
57
56
|
"localization:create": "node scripts/localizations.mjs create",
|
|
58
57
|
"localization:sync": "node scripts/localizations.mjs sync",
|
|
59
|
-
"release": "pnpm run changeset:version && pnpm install --lockfile-only && git add package.json pnpm-lock.yaml CHANGELOG.md .changeset && git commit -m \"chore: version packages [skip ci]\" && changeset publish && git push --follow-tags",
|
|
58
|
+
"release": "pnpm run changeset:version && pnpm install --lockfile-only && git add package.json pnpm-lock.yaml CHANGELOG.md .changeset && git commit -m \"chore: version packages [skip ci]\" && changeset publish && git push --follow-tags && VERSION=$(node -p \"require('./package.json').version\") && gh release create \"v$VERSION\" --title \"v$VERSION\" --generate-notes --verify-tag",
|
|
60
59
|
"test": "pnpm run build && node --test"
|
|
61
60
|
}
|
|
62
61
|
}
|