@pie-qti/i18n 1.0.0-beta.0 → 1.0.0-beta.2
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 +104 -55
- package/dist/core/I18n.d.ts +149 -0
- package/dist/core/I18n.js +348 -0
- package/dist/core/I18n.js.map +1 -0
- package/dist/core/I18nProvider.d.ts +91 -0
- package/dist/core/I18nProvider.js +9 -0
- package/dist/core/I18nProvider.js.map +1 -0
- package/dist/core/accessible-text.d.ts +36 -0
- package/dist/core/accessible-text.js +54 -0
- package/dist/core/accessible-text.js.map +1 -0
- package/dist/core/direction.d.ts +39 -0
- package/dist/core/direction.js +96 -0
- package/dist/core/direction.js.map +1 -0
- package/dist/core/language-tags.d.ts +47 -0
- package/dist/core/language-tags.js +91 -0
- package/dist/core/language-tags.js.map +1 -0
- package/dist/core/negotiation.d.ts +41 -0
- package/dist/core/negotiation.js +71 -0
- package/dist/core/negotiation.js.map +1 -0
- package/dist/core/numbering.d.ts +31 -0
- package/dist/core/numbering.js +88 -0
- package/dist/core/numbering.js.map +1 -0
- package/dist/core/pseudo.d.ts +33 -0
- package/dist/core/pseudo.js +44 -0
- package/dist/core/pseudo.js.map +1 -0
- package/dist/core/types.d.ts +29 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/ar.d.ts +926 -0
- package/dist/locales/ar.js +963 -0
- package/dist/locales/ar.js.map +1 -0
- package/dist/locales/en.d.ts +870 -0
- package/dist/locales/en.js +909 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es.d.ts +874 -0
- package/dist/locales/es.js +901 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fr.d.ts +873 -0
- package/dist/locales/fr.js +900 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/nl.d.ts +872 -0
- package/dist/locales/nl.js +898 -0
- package/dist/locales/nl.js.map +1 -0
- package/dist/locales/ro.d.ts +873 -0
- package/dist/locales/ro.js +900 -0
- package/dist/locales/ro.js.map +1 -0
- package/dist/locales/th.d.ts +872 -0
- package/dist/locales/th.js +899 -0
- package/dist/locales/th.js.map +1 -0
- package/dist/locales/zh-Hans.d.ts +870 -0
- package/dist/locales/zh-Hans.js +905 -0
- package/dist/locales/zh-Hans.js.map +1 -0
- package/dist/providers/SvelteI18nProvider.d.ts +58 -0
- package/dist/providers/SvelteI18nProvider.js +102 -0
- package/dist/providers/SvelteI18nProvider.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for i18n system
|
|
3
|
+
*/
|
|
4
|
+
import type en from '../locales/en.js';
|
|
5
|
+
import type { FrameworkCatalogCode } from './negotiation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Locale tags with a framework catalog.
|
|
8
|
+
*
|
|
9
|
+
* Catalogs are keyed by language (`FrameworkCatalogCode`: `en`, `es`, `ar`,
|
|
10
|
+
* `zh-Hans` …). The region-qualified tags are kept as members because hosts
|
|
11
|
+
* pass them; negotiation resolves each to its language's catalog, as it does
|
|
12
|
+
* any other tag (`es-MX`, `ar_EG`). Clients provide translations for other
|
|
13
|
+
* locales via the customMessages parameter.
|
|
14
|
+
*/
|
|
15
|
+
export type FrameworkLocaleCode = FrameworkCatalogCode | 'en-US' | 'es-ES' | 'fr-FR' | 'nl-NL' | 'ro-RO' | 'th-TH' | 'zh-CN' | 'ar-SA';
|
|
16
|
+
export type LocaleCode = FrameworkLocaleCode | (string & {});
|
|
17
|
+
type NestedKeyOfHelper<ObjectType extends object> = {
|
|
18
|
+
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOfHelper<ObjectType[Key]>}` : `${Key}`;
|
|
19
|
+
}[keyof ObjectType & (string | number)];
|
|
20
|
+
export type MessageKey = NestedKeyOfHelper<typeof en>;
|
|
21
|
+
export interface InterpolationValues {
|
|
22
|
+
[key: string]: string | number;
|
|
23
|
+
}
|
|
24
|
+
export interface PluralOptions {
|
|
25
|
+
count: number;
|
|
26
|
+
[key: string]: string | number;
|
|
27
|
+
}
|
|
28
|
+
export type LocaleMessages = Record<string, any>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Type definitions for i18n system\n */\n\nimport type en from '../locales/en.js';\nimport type { FrameworkCatalogCode } from './negotiation.js';\n\n/**\n * Locale tags with a framework catalog.\n *\n * Catalogs are keyed by language (`FrameworkCatalogCode`: `en`, `es`, `ar`,\n * `zh-Hans` …). The region-qualified tags are kept as members because hosts\n * pass them; negotiation resolves each to its language's catalog, as it does\n * any other tag (`es-MX`, `ar_EG`). Clients provide translations for other\n * locales via the customMessages parameter.\n */\nexport type FrameworkLocaleCode =\n\t| FrameworkCatalogCode\n\t| 'en-US' // English (United States)\n\t| 'es-ES' // Spanish (Spain)\n\t| 'fr-FR' // French (France)\n\t| 'nl-NL' // Dutch (Netherlands)\n\t| 'ro-RO' // Romanian (Romania)\n\t| 'th-TH' // Thai (Thailand)\n\t| 'zh-CN' // Chinese (Simplified, China)\n\t| 'ar-SA'; // Arabic (Saudi Arabia)\n\n// Allow any locale code (clients can provide custom locales)\nexport type LocaleCode = FrameworkLocaleCode | (string & {});\n\n// Utility type to extract nested keys as dot-notation strings\ntype NestedKeyOfHelper<ObjectType extends object> = {\n\t[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object\n\t\t? `${Key}` | `${Key}.${NestedKeyOfHelper<ObjectType[Key]>}`\n\t\t: `${Key}`;\n}[keyof ObjectType & (string | number)];\n\n// Message key generated from the English catalog structure\nexport type MessageKey = NestedKeyOfHelper<typeof en>;\n\n// Interpolation values for dynamic message content\nexport interface InterpolationValues {\n\t[key: string]: string | number;\n}\n\n// Pluralization options\nexport interface PluralOptions {\n\tcount: number;\n\t[key: string]: string | number;\n}\n\n// Locale message structure\nexport type LocaleMessages = Record<string, any>;\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API exports for @pie-qti/i18n package
|
|
3
|
+
*/
|
|
4
|
+
export type { I18nProvider, InterpolationValues, PluralOptions } from './core/I18nProvider.js';
|
|
5
|
+
export { DefaultI18nProvider, createDefaultI18nProvider } from './core/I18n.js';
|
|
6
|
+
export { SvelteI18nProvider, createSvelteI18nProvider, createDefaultSvelteI18nProvider, DEFAULT_LOCALE_STORAGE_KEY, } from './providers/SvelteI18nProvider.js';
|
|
7
|
+
export type { SvelteI18nProviderOptions } from './providers/SvelteI18nProvider.js';
|
|
8
|
+
export { normalizeLanguageTag, languageTagLookupSequence, languageTagScript, languageTagScriptsMatch, } from './core/language-tags.js';
|
|
9
|
+
export { FRAMEWORK_CATALOGS, localeLookupSequence, matchLanguageTag, resolveFrameworkLocale, } from './core/negotiation.js';
|
|
10
|
+
export type { FrameworkCatalogCode } from './core/negotiation.js';
|
|
11
|
+
export { canonicalLanguageTag, contentLanguageAttributes, interfaceLocaleAttributes, languageDirection, } from './core/direction.js';
|
|
12
|
+
export type { LanguageAttributes, TextDirection } from './core/direction.js';
|
|
13
|
+
export { formattingLocale, numberingSystemFor } from './core/numbering.js';
|
|
14
|
+
export { formatList, isImeComposing, joinSentences, translate, translatePlural } from './core/accessible-text.js';
|
|
15
|
+
export { PSEUDO_LOCALE_EXPANDED, PSEUDO_LOCALE_RTL, pseudoLocalize } from './core/pseudo.js';
|
|
16
|
+
export type { PseudoLocalizeOptions } from './core/pseudo.js';
|
|
17
|
+
export type { LocaleCode, FrameworkLocaleCode, MessageKey, LocaleMessages, } from './core/types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API exports for @pie-qti/i18n package
|
|
3
|
+
*/
|
|
4
|
+
// Default implementation
|
|
5
|
+
export { DefaultI18nProvider, createDefaultI18nProvider } from './core/I18n.js';
|
|
6
|
+
// Svelte-specific provider with opt-in persistence and reload
|
|
7
|
+
export { SvelteI18nProvider, createSvelteI18nProvider, createDefaultSvelteI18nProvider, DEFAULT_LOCALE_STORAGE_KEY, } from './providers/SvelteI18nProvider.js';
|
|
8
|
+
// Language tags and locale negotiation
|
|
9
|
+
export { normalizeLanguageTag, languageTagLookupSequence, languageTagScript, languageTagScriptsMatch, } from './core/language-tags.js';
|
|
10
|
+
export { FRAMEWORK_CATALOGS, localeLookupSequence, matchLanguageTag, resolveFrameworkLocale, } from './core/negotiation.js';
|
|
11
|
+
// Writing direction and the lang/dir pairs players write on their roots
|
|
12
|
+
export { canonicalLanguageTag, contentLanguageAttributes, interfaceLocaleAttributes, languageDirection, } from './core/direction.js';
|
|
13
|
+
// Digits and calendar for locale formatting
|
|
14
|
+
export { formattingLocale, numberingSystemFor } from './core/numbering.js';
|
|
15
|
+
// Accessible names and live-region messages
|
|
16
|
+
export { formatList, isImeComposing, joinSentences, translate, translatePlural } from './core/accessible-text.js';
|
|
17
|
+
// Pseudo-locales for layout and coverage testing
|
|
18
|
+
export { PSEUDO_LOCALE_EXPANDED, PSEUDO_LOCALE_RTL, pseudoLocalize } from './core/pseudo.js';
|
|
19
|
+
// Example components (commented out - Svelte files need special build process)
|
|
20
|
+
// export { default as LocaleSwitcher } from './components/LocaleSwitcher.svelte';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,yBAAyB;AACzB,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,8DAA8D;AAC9D,OAAO,EACN,kBAAkB,EAClB,wBAAwB,EACxB,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,mCAAmC,CAAC;AAG3C,uCAAuC;AACvC,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAG/B,wEAAwE;AACxE,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,4CAA4C;AAC5C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,4CAA4C;AAC5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAElH,iDAAiD;AACjD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAW7F,+EAA+E;AAC/E,kFAAkF","sourcesContent":["/**\n * Public API exports for @pie-qti/i18n package\n */\n\n// Core interface (framework-agnostic)\nexport type { I18nProvider, InterpolationValues, PluralOptions } from './core/I18nProvider.js';\n\n// Default implementation\nexport { DefaultI18nProvider, createDefaultI18nProvider } from './core/I18n.js';\n\n// Svelte-specific provider with opt-in persistence and reload\nexport {\n\tSvelteI18nProvider,\n\tcreateSvelteI18nProvider,\n\tcreateDefaultSvelteI18nProvider,\n\tDEFAULT_LOCALE_STORAGE_KEY,\n} from './providers/SvelteI18nProvider.js';\nexport type { SvelteI18nProviderOptions } from './providers/SvelteI18nProvider.js';\n\n// Language tags and locale negotiation\nexport {\n\tnormalizeLanguageTag,\n\tlanguageTagLookupSequence,\n\tlanguageTagScript,\n\tlanguageTagScriptsMatch,\n} from './core/language-tags.js';\nexport {\n\tFRAMEWORK_CATALOGS,\n\tlocaleLookupSequence,\n\tmatchLanguageTag,\n\tresolveFrameworkLocale,\n} from './core/negotiation.js';\nexport type { FrameworkCatalogCode } from './core/negotiation.js';\n\n// Writing direction and the lang/dir pairs players write on their roots\nexport {\n\tcanonicalLanguageTag,\n\tcontentLanguageAttributes,\n\tinterfaceLocaleAttributes,\n\tlanguageDirection,\n} from './core/direction.js';\nexport type { LanguageAttributes, TextDirection } from './core/direction.js';\n\n// Digits and calendar for locale formatting\nexport { formattingLocale, numberingSystemFor } from './core/numbering.js';\n\n// Accessible names and live-region messages\nexport { formatList, isImeComposing, joinSentences, translate, translatePlural } from './core/accessible-text.js';\n\n// Pseudo-locales for layout and coverage testing\nexport { PSEUDO_LOCALE_EXPANDED, PSEUDO_LOCALE_RTL, pseudoLocalize } from './core/pseudo.js';\nexport type { PseudoLocalizeOptions } from './core/pseudo.js';\n\n// Types\nexport type {\n\tLocaleCode,\n\tFrameworkLocaleCode,\n\tMessageKey,\n\tLocaleMessages,\n} from './core/types.js';\n\n// Example components (commented out - Svelte files need special build process)\n// export { default as LocaleSwitcher } from './components/LocaleSwitcher.svelte';\n"]}
|