@pie-qti/i18n 0.1.27 → 1.0.0-beta.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.
Files changed (41) hide show
  1. package/README.md +52 -35
  2. package/package.json +1 -1
  3. package/dist/core/I18n.d.ts +0 -119
  4. package/dist/core/I18n.js +0 -325
  5. package/dist/core/I18n.js.map +0 -1
  6. package/dist/core/I18nProvider.d.ts +0 -83
  7. package/dist/core/I18nProvider.js +0 -9
  8. package/dist/core/I18nProvider.js.map +0 -1
  9. package/dist/core/types.d.ts +0 -19
  10. package/dist/core/types.js +0 -5
  11. package/dist/core/types.js.map +0 -1
  12. package/dist/index.d.ts +0 -7
  13. package/dist/index.js +0 -10
  14. package/dist/index.js.map +0 -1
  15. package/dist/locales/ar-SA.d.ts +0 -861
  16. package/dist/locales/ar-SA.js +0 -898
  17. package/dist/locales/ar-SA.js.map +0 -1
  18. package/dist/locales/en-US.d.ts +0 -809
  19. package/dist/locales/en-US.js +0 -848
  20. package/dist/locales/en-US.js.map +0 -1
  21. package/dist/locales/es-ES.d.ts +0 -812
  22. package/dist/locales/es-ES.js +0 -839
  23. package/dist/locales/es-ES.js.map +0 -1
  24. package/dist/locales/fr-FR.d.ts +0 -811
  25. package/dist/locales/fr-FR.js +0 -838
  26. package/dist/locales/fr-FR.js.map +0 -1
  27. package/dist/locales/nl-NL.d.ts +0 -811
  28. package/dist/locales/nl-NL.js +0 -837
  29. package/dist/locales/nl-NL.js.map +0 -1
  30. package/dist/locales/ro-RO.d.ts +0 -811
  31. package/dist/locales/ro-RO.js +0 -838
  32. package/dist/locales/ro-RO.js.map +0 -1
  33. package/dist/locales/th-TH.d.ts +0 -811
  34. package/dist/locales/th-TH.js +0 -838
  35. package/dist/locales/th-TH.js.map +0 -1
  36. package/dist/locales/zh-CN.d.ts +0 -809
  37. package/dist/locales/zh-CN.js +0 -844
  38. package/dist/locales/zh-CN.js.map +0 -1
  39. package/dist/providers/SvelteI18nProvider.d.ts +0 -39
  40. package/dist/providers/SvelteI18nProvider.js +0 -107
  41. package/dist/providers/SvelteI18nProvider.js.map +0 -1
@@ -1,83 +0,0 @@
1
- /**
2
- * Framework-agnostic i18n provider interface
3
- *
4
- * This interface defines the contract for internationalization services.
5
- * Users can provide their own implementations (ICU MessageFormat, i18next, etc.)
6
- * or use the default implementation provided by the framework.
7
- */
8
- export interface I18nProvider {
9
- /**
10
- * Get the current locale code (e.g., 'en-US', 'fr-FR')
11
- */
12
- getLocale(): string;
13
- /**
14
- * Set the current locale and optionally load locale messages
15
- * @param locale - BCP 47 locale code
16
- */
17
- setLocale(locale: string): Promise<void> | void;
18
- /**
19
- * Translate a message key with optional default and/or interpolation
20
- * @param key - Message key (e.g., 'common.submit', 'assessment.question')
21
- * @param defaultOrValues - Optional default string or interpolation values
22
- * @param values - Optional interpolation values (if second arg is default string)
23
- * @returns Translated message, default, or key if not found
24
- */
25
- t(key: string, defaultOrValues?: Record<string, any> | string, values?: Record<string, any>): string;
26
- /**
27
- * Optional: Pluralization support
28
- * @param key - Base message key
29
- * @param options - Options including count and interpolation values
30
- * @returns Pluralized and translated message
31
- */
32
- plural?(key: string, options: {
33
- count: number;
34
- [key: string]: any;
35
- }): string;
36
- /**
37
- * Optional: Writing direction of the current locale
38
- *
39
- * Components reflect this onto a `dir` attribute. `direction` is an inherited
40
- * CSS property, so a `dir` on the host element crosses into shadow content
41
- * without any per-component wiring.
42
- *
43
- * @returns 'rtl' for right-to-left locales, otherwise 'ltr'
44
- */
45
- getDirection?(): 'ltr' | 'rtl';
46
- /**
47
- * Optional: A view of this provider fixed to another locale
48
- *
49
- * Lets two players on one page render different locales without either
50
- * mutating the other's active locale. A provider that cannot produce such a
51
- * view simply omits this, and callers fall back to the provider itself.
52
- *
53
- * @param locale - BCP 47 locale code for the view
54
- */
55
- withLocale?(locale: string): I18nProvider;
56
- /**
57
- * Optional: Format number according to locale
58
- * @param value - Number to format
59
- * @param options - Intl.NumberFormat options
60
- * @returns Formatted number string
61
- */
62
- formatNumber?(value: number, options?: Intl.NumberFormatOptions): string;
63
- /**
64
- * Optional: Format date according to locale
65
- * @param date - Date to format
66
- * @param options - Intl.DateTimeFormat options
67
- * @returns Formatted date string
68
- */
69
- formatDate?(date: Date, options?: Intl.DateTimeFormatOptions): string;
70
- }
71
- /**
72
- * Interpolation values for dynamic message content
73
- */
74
- export interface InterpolationValues {
75
- [key: string]: string | number;
76
- }
77
- /**
78
- * Pluralization options
79
- */
80
- export interface PluralOptions {
81
- count: number;
82
- [key: string]: string | number;
83
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Framework-agnostic i18n provider interface
3
- *
4
- * This interface defines the contract for internationalization services.
5
- * Users can provide their own implementations (ICU MessageFormat, i18next, etc.)
6
- * or use the default implementation provided by the framework.
7
- */
8
- export {};
9
- //# sourceMappingURL=I18nProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"I18nProvider.js","sourceRoot":"","sources":["../../src/core/I18nProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Framework-agnostic i18n provider interface\n *\n * This interface defines the contract for internationalization services.\n * Users can provide their own implementations (ICU MessageFormat, i18next, etc.)\n * or use the default implementation provided by the framework.\n */\n\nexport interface I18nProvider {\n\t/**\n\t * Get the current locale code (e.g., 'en-US', 'fr-FR')\n\t */\n\tgetLocale(): string;\n\n\t/**\n\t * Set the current locale and optionally load locale messages\n\t * @param locale - BCP 47 locale code\n\t */\n\tsetLocale(locale: string): Promise<void> | void;\n\n\t/**\n\t * Translate a message key with optional default and/or interpolation\n\t * @param key - Message key (e.g., 'common.submit', 'assessment.question')\n\t * @param defaultOrValues - Optional default string or interpolation values\n\t * @param values - Optional interpolation values (if second arg is default string)\n\t * @returns Translated message, default, or key if not found\n\t */\n\tt(key: string, defaultOrValues?: Record<string, any> | string, values?: Record<string, any>): string;\n\n\t/**\n\t * Optional: Pluralization support\n\t * @param key - Base message key\n\t * @param options - Options including count and interpolation values\n\t * @returns Pluralized and translated message\n\t */\n\tplural?(key: string, options: { count: number; [key: string]: any }): string;\n\n\t/**\n\t * Optional: Writing direction of the current locale\n\t *\n\t * Components reflect this onto a `dir` attribute. `direction` is an inherited\n\t * CSS property, so a `dir` on the host element crosses into shadow content\n\t * without any per-component wiring.\n\t *\n\t * @returns 'rtl' for right-to-left locales, otherwise 'ltr'\n\t */\n\tgetDirection?(): 'ltr' | 'rtl';\n\n\t/**\n\t * Optional: A view of this provider fixed to another locale\n\t *\n\t * Lets two players on one page render different locales without either\n\t * mutating the other's active locale. A provider that cannot produce such a\n\t * view simply omits this, and callers fall back to the provider itself.\n\t *\n\t * @param locale - BCP 47 locale code for the view\n\t */\n\twithLocale?(locale: string): I18nProvider;\n\n\t/**\n\t * Optional: Format number according to locale\n\t * @param value - Number to format\n\t * @param options - Intl.NumberFormat options\n\t * @returns Formatted number string\n\t */\n\tformatNumber?(value: number, options?: Intl.NumberFormatOptions): string;\n\n\t/**\n\t * Optional: Format date according to locale\n\t * @param date - Date to format\n\t * @param options - Intl.DateTimeFormat options\n\t * @returns Formatted date string\n\t */\n\tformatDate?(date: Date, options?: Intl.DateTimeFormatOptions): string;\n}\n\n/**\n * Interpolation values for dynamic message content\n */\nexport interface InterpolationValues {\n\t[key: string]: string | number;\n}\n\n/**\n * Pluralization options\n */\nexport interface PluralOptions {\n\tcount: number;\n\t[key: string]: string | number;\n}\n"]}
@@ -1,19 +0,0 @@
1
- /**
2
- * Type definitions for i18n system
3
- */
4
- import type enUS from '../locales/en-US.js';
5
- export type FrameworkLocaleCode = 'en-US' | 'es-ES' | 'fr-FR' | 'nl-NL' | 'ro-RO' | 'th-TH' | 'zh-CN' | 'ar-SA';
6
- export type LocaleCode = FrameworkLocaleCode | (string & {});
7
- type NestedKeyOfHelper<ObjectType extends object> = {
8
- [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOfHelper<ObjectType[Key]>}` : `${Key}`;
9
- }[keyof ObjectType & (string | number)];
10
- export type MessageKey = NestedKeyOfHelper<typeof enUS>;
11
- export interface InterpolationValues {
12
- [key: string]: string | number;
13
- }
14
- export interface PluralOptions {
15
- count: number;
16
- [key: string]: string | number;
17
- }
18
- export type LocaleMessages = Record<string, any>;
19
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * Type definitions for i18n system
3
- */
4
- export {};
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
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 enUS from '../locales/en-US.js';\n\n// Framework-provided locale codes (BCP 47 format)\n// The framework provides a minimal set of locales. Clients can provide their own\n// translations for additional locales via the customMessages parameter.\nexport type FrameworkLocaleCode =\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 English locale structure\nexport type MessageKey = NestedKeyOfHelper<typeof enUS>;\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 DELETED
@@ -1,7 +0,0 @@
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 } from './providers/SvelteI18nProvider.js';
7
- export type { LocaleCode, MessageKey, LocaleMessages, } from './core/types.js';
package/dist/index.js DELETED
@@ -1,10 +0,0 @@
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 reactive stores
7
- export { SvelteI18nProvider, createSvelteI18nProvider, createDefaultSvelteI18nProvider } from './providers/SvelteI18nProvider.js';
8
- // Example components (commented out - Svelte files need special build process)
9
- // export { default as LocaleSwitcher } from './components/LocaleSwitcher.svelte';
10
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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,gDAAgD;AAChD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AASlI,+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 reactive stores\nexport { SvelteI18nProvider, createSvelteI18nProvider, createDefaultSvelteI18nProvider } from './providers/SvelteI18nProvider.js';\n\n// Types\nexport type {\n\tLocaleCode,\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"]}