@cocoar/vue-localization 0.1.0-beta.24 → 0.1.0-beta.34

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.
@@ -0,0 +1,54 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { CoarLocalizationService } from './localization-service';
3
+ import { CoarLocalizationData } from './types';
4
+ /**
5
+ * Access the full localization service.
6
+ * Returns null if the localization plugin is not installed.
7
+ */
8
+ export declare function useLocalization(): CoarLocalizationService | null;
9
+ /**
10
+ * Reactive localization composable with formatting utilities.
11
+ * Provides reactive language, locale data, and formatting functions
12
+ * that automatically update when the language changes.
13
+ */
14
+ export declare function useL10n(): {
15
+ /** Current language (reactive) */
16
+ language: Ref<string, string>;
17
+ /** Current locale data (reactive) */
18
+ localeData: ComputedRef<CoarLocalizationData | undefined>;
19
+ /** Format a number */
20
+ fmtNumber: (value: number, decimals?: number) => string;
21
+ /** Format a currency value */
22
+ fmtCurrency: (value: number, currencyCode?: string) => string;
23
+ /** Format a percentage (0.25 → "25%") */
24
+ fmtPercent: (value: number, decimals?: number) => string;
25
+ /** Format a date */
26
+ fmtDate: (value: Date | string, includeTime?: boolean) => string;
27
+ };
28
+ /**
29
+ * i18n composable for translations.
30
+ * Provides a reactive translation function.
31
+ */
32
+ export declare function useI18n(): {
33
+ /** Current language (reactive) */
34
+ language: Readonly<Ref<string, string>>;
35
+ /**
36
+ * Translate a key. Returns the key if no translation found.
37
+ * Reactive — updates when language changes.
38
+ */
39
+ t: (key: string, params?: Record<string, unknown>, fallback?: string) => string;
40
+ /**
41
+ * Create a computed translation ref that reacts to language changes.
42
+ */
43
+ tRef: (key: string, params?: Record<string, unknown>, fallback?: string) => ComputedRef<string>;
44
+ };
45
+ /**
46
+ * Timezone composable.
47
+ */
48
+ export declare function useTimezone(): {
49
+ /** Current timezone (reactive IANA identifier) */
50
+ timezone: Readonly<Ref<string, string>>;
51
+ /** Re-resolve timezone from providers */
52
+ refresh: () => void | undefined;
53
+ };
54
+ //# sourceMappingURL=composables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../src/composables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,OAAO;IAYnB,kCAAkC;;IAElC,qCAAqC;;IAErC,sBAAsB;uBACH,MAAM,aAAa,MAAM,KAAG,MAAM;IAKrD,8BAA8B;yBACT,MAAM,iBAAiB,MAAM,KAAG,MAAM;IAK3D,yCAAyC;wBACrB,MAAM,aAAa,MAAM,KAAG,MAAM;IAKtD,oBAAoB;qBACH,IAAI,GAAG,MAAM,4BAAwB,MAAM;EAM/D;AAED;;;GAGG;AACH,wBAAgB,OAAO;IAInB,kCAAkC;;IAGlC;;;OAGG;aACM,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,MAAM,KAAG,MAAM;IAK7E;;OAEG;gBACS,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,MAAM,KAAG,WAAW,CAAC,MAAM,CAAC;EAKhG;AAED;;GAEG;AACH,wBAAgB,WAAW;IAIvB,kDAAkD;;IAUlD,yCAAyC;;EAG5C"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Interpolate parameters into a translation string.
3
+ * Replaces {param} placeholders with values from the params object.
4
+ * Missing params are replaced with empty string (Angular-compatible behavior).
5
+ *
6
+ * @example
7
+ * interpolate('Hello, {name}!', { name: 'Alice' }) → 'Hello, Alice!'
8
+ * interpolate('{count} items', { count: 42 }) → '42 items'
9
+ * interpolate('Hello, {name}!', {}) → 'Hello, !'
10
+ */
11
+ export declare function interpolate(template: string, params?: Record<string, unknown>): string;
12
+ /**
13
+ * Check if a returned translation value is actually missing.
14
+ * Missing means: null, undefined, empty, whitespace-only, or equals the key itself.
15
+ */
16
+ export declare function isMissingTranslation(key: string, value: string | null | undefined): boolean;
17
+ //# sourceMappingURL=interpolate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/i18n/interpolate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAOR;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAI3F"}
@@ -0,0 +1,16 @@
1
+ import { CoarTranslationSource, CoarTranslations } from '../types';
2
+ /**
3
+ * Generates common translations from browser Intl APIs.
4
+ * Always registered as the first translation source so HTTP translations can override.
5
+ *
6
+ * Generated keys:
7
+ * - common.today, common.yesterday, common.tomorrow (Intl.RelativeTimeFormat)
8
+ * - common.month.1–12 (full month names, 1=January)
9
+ * - common.month.short.1–12 (abbreviated month names)
10
+ * - common.weekday.1–7 (full day names, 1=Monday, 7=Sunday)
11
+ * - common.weekday.short.1–7 (abbreviated day names)
12
+ */
13
+ export declare class IntlTranslationSource implements CoarTranslationSource {
14
+ load(language: string): Promise<CoarTranslations | null>;
15
+ }
16
+ //# sourceMappingURL=intl-translation-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intl-translation-source.d.ts","sourceRoot":"","sources":["../../src/i18n/intl-translation-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,YAAW,qBAAqB;IAC3D,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CA0C/D"}
@@ -0,0 +1,47 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ import { CoarTranslations } from '../types';
3
+ /**
4
+ * Reactive store for translations.
5
+ * Stores flat key-value maps per language, supports nested JSON flattening.
6
+ */
7
+ export declare class CoarTranslationStore {
8
+ private readonly data;
9
+ private readonly _version;
10
+ /** Reactive version counter — use in computed() to react to changes */
11
+ readonly version: Readonly<Ref<number>>;
12
+ /** Reactive set of loaded language codes */
13
+ readonly loadedLanguages: ComputedRef<Set<string>>;
14
+ /**
15
+ * Set translations for a language. Replaces any existing translations.
16
+ * Nested objects are flattened to dot-separated keys.
17
+ */
18
+ setTranslations(language: string, translations: CoarTranslations): void;
19
+ /**
20
+ * Merge additional translations into existing ones for a language.
21
+ */
22
+ updateTranslations(language: string, translations: CoarTranslations): void;
23
+ /**
24
+ * Get a single translation by key.
25
+ */
26
+ getTranslation(language: string, key: string): string | undefined;
27
+ /**
28
+ * Get all translations for a language.
29
+ */
30
+ getTranslations(language: string): Map<string, string> | undefined;
31
+ /**
32
+ * Set a single translation.
33
+ */
34
+ setTranslation(language: string, key: string, value: string): void;
35
+ hasLanguage(language: string): boolean;
36
+ /**
37
+ * Remove all translations for a specific language.
38
+ */
39
+ clearLanguage(language: string): void;
40
+ /**
41
+ * Bump version to trigger reactivity without changing data.
42
+ * Useful after external data updates.
43
+ */
44
+ touch(): void;
45
+ clear(): void;
46
+ }
47
+ //# sourceMappingURL=translation-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-store.d.ts","sourceRoot":"","sources":["../../src/i18n/translation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0C;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAiB;IAExD,4CAA4C;IAC5C,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAG/C;IAEH;;;OAGG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,GAAG,IAAI;IAOvE;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,GAAG,IAAI;IAO1E;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKjE;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;IAKlE;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUlE,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKtC;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKrC;;;OAGG;IACH,KAAK,IAAI,IAAI;IAIb,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,14 @@
1
+ export type { CoarLocalizationData, CoarDateFormatData, CoarNumberFormatData, CoarCurrencyFormatData, CoarPercentFormatData, CoarLocalizationConfig, CoarTimezoneProvider, CoarTranslations, CoarLocaleDataSource, CoarTranslationSource, } from './types';
2
+ export { CoarLocalizationService } from './localization-service';
3
+ export { CoarLocalizationDataStore } from './l10n/localization-data-store';
4
+ export { IntlLocaleDataSource } from './l10n/intl-locale-data-source';
5
+ export { mergeLocalizationData } from './l10n/merge-localization-data';
6
+ export { formatNumber, formatCurrency, formatPercent, formatDate } from './l10n/formatters';
7
+ export { CoarTranslationStore } from './i18n/translation-store';
8
+ export { interpolate, isMissingTranslation } from './i18n/interpolate';
9
+ export { IntlTranslationSource } from './i18n/intl-translation-source';
10
+ export { CoarTimezoneService, BrowserTimezoneProvider } from './timezone/timezone-service';
11
+ export { createCoarLocalization } from './plugin';
12
+ export { COAR_LOCALIZATION_KEY } from './injection-keys';
13
+ export { useLocalization, useL10n, useI18n, useTimezone } from './composables';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { InjectionKey } from 'vue';
2
+ import { CoarLocalizationService } from './localization-service';
3
+ /**
4
+ * Injection key for the localization service.
5
+ * Used by useLocalization(), useI18n(), and useTimezone() composables.
6
+ * Also used by vue-ui components for optional inject.
7
+ */
8
+ export declare const COAR_LOCALIZATION_KEY: InjectionKey<CoarLocalizationService>;
9
+ //# sourceMappingURL=injection-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection-keys.d.ts","sourceRoot":"","sources":["../src/injection-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,uBAAuB,CAC3C,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { CoarLocalizationData, CoarNumberFormatData, CoarDateFormatData } from '../types';
2
+ /**
3
+ * Format a number using locale-specific separators.
4
+ */
5
+ export declare function formatNumber(value: number, data: CoarNumberFormatData, decimals?: number): string;
6
+ /**
7
+ * Format a number as currency.
8
+ */
9
+ export declare function formatCurrency(value: number, data: CoarLocalizationData, currencyCode?: string): string;
10
+ /**
11
+ * Format a decimal value as percent (0.25 → "25%").
12
+ */
13
+ export declare function formatPercent(value: number, data: CoarLocalizationData, decimals?: number): string;
14
+ /**
15
+ * Format a Date using locale date format data.
16
+ * Supports Date objects and ISO date strings.
17
+ */
18
+ export declare function formatDate(value: Date | string, data: CoarDateFormatData, includeTime?: boolean): string;
19
+ //# sourceMappingURL=formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/l10n/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,oBAAoB,EAC1B,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,IAAI,GAAG,MAAM,EACpB,IAAI,EAAE,kBAAkB,EACxB,WAAW,UAAQ,GAClB,MAAM,CAgCR"}
@@ -0,0 +1,9 @@
1
+ import { CoarLocalizationData, CoarLocaleDataSource } from '../types';
2
+ /**
3
+ * Extracts locale formatting data from the browser's Intl API.
4
+ * Always available as the base/fallback data source.
5
+ */
6
+ export declare class IntlLocaleDataSource implements CoarLocaleDataSource {
7
+ load(language: string): Promise<CoarLocalizationData>;
8
+ }
9
+ //# sourceMappingURL=intl-locale-data-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intl-locale-data-source.d.ts","sourceRoot":"","sources":["../../src/l10n/intl-locale-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAKpB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,oBAAoB;IACzD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAS5D"}
@@ -0,0 +1,18 @@
1
+ import { Ref } from 'vue';
2
+ import { CoarLocalizationData } from '../types';
3
+ /**
4
+ * Reactive store for locale-specific formatting data.
5
+ * Uses a Map keyed by locale code with a version counter for reactivity.
6
+ */
7
+ export declare class CoarLocalizationDataStore {
8
+ private readonly data;
9
+ private readonly _version;
10
+ /** Reactive version counter — watch this to react to data changes */
11
+ readonly version: Readonly<Ref<number>>;
12
+ setLocaleData(locale: string, data: CoarLocalizationData): void;
13
+ getLocaleData(locale: string): CoarLocalizationData | undefined;
14
+ hasLocaleData(locale: string): boolean;
15
+ removeLocaleData(locale: string): void;
16
+ clear(): void;
17
+ }
18
+ //# sourceMappingURL=localization-data-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization-data-store.d.ts","sourceRoot":"","sources":["../../src/l10n/localization-data-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;;GAGG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2C;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAiB;IAExD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAK/D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAM/D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAKtC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKtC,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,7 @@
1
+ import { CoarLocalizationData } from '../types';
2
+ /**
3
+ * Deep-merge partial locale data into a base locale data object.
4
+ * Partial values override base values; arrays and objects are merged at one level.
5
+ */
6
+ export declare function mergeLocalizationData(base: CoarLocalizationData, partial: Partial<CoarLocalizationData>): CoarLocalizationData;
7
+ //# sourceMappingURL=merge-localization-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-localization-data.d.ts","sourceRoot":"","sources":["../../src/l10n/merge-localization-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACrC,oBAAoB,CActB"}
@@ -0,0 +1,61 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ import { CoarLocalizationConfig, CoarLocalizationData, CoarLocaleDataSource, CoarTranslationSource } from './types';
3
+ import { CoarLocalizationDataStore } from './l10n/localization-data-store';
4
+ import { CoarTranslationStore } from './i18n/translation-store';
5
+ import { CoarTimezoneService } from './timezone/timezone-service';
6
+ /**
7
+ * Core localization service.
8
+ * Manages language state, locale data loading, translations, and timezone.
9
+ */
10
+ export declare class CoarLocalizationService {
11
+ private readonly defaultLanguage;
12
+ private readonly _language;
13
+ private readonly _loading;
14
+ readonly l10nStore: CoarLocalizationDataStore;
15
+ readonly i18nStore: CoarTranslationStore;
16
+ readonly timezoneService: CoarTimezoneService;
17
+ private readonly l10nSources;
18
+ private readonly i18nSources;
19
+ /** Reactive current language */
20
+ get language(): Readonly<Ref<string>>;
21
+ /** Reactive loading state */
22
+ get loading(): Readonly<Ref<boolean>>;
23
+ /** Computed current locale data — reactive, updates on language change */
24
+ readonly localeData: ComputedRef<CoarLocalizationData | undefined>;
25
+ constructor(config?: CoarLocalizationConfig);
26
+ /** Get the configured default language */
27
+ getDefaultLanguage(): string;
28
+ /**
29
+ * Change the current language.
30
+ * Loads locale data and translations if not already cached.
31
+ */
32
+ setLanguage(language: string): Promise<void>;
33
+ /**
34
+ * Preload data for a language without switching to it.
35
+ */
36
+ preloadLanguage(language: string): Promise<void>;
37
+ /**
38
+ * Force reload data for a language from all sources, clearing the cache.
39
+ * Useful when external data changes at runtime (e.g. SignalR push, user profile update).
40
+ * If no language is specified, reloads the current language.
41
+ */
42
+ reloadLanguage(language?: string): Promise<void>;
43
+ /**
44
+ * Translate a key using the current language.
45
+ * For regional locales (e.g. de-AT), falls back to the base language (de).
46
+ * Returns the key itself if no translation is found.
47
+ */
48
+ t(key: string, params?: Record<string, unknown>, fallback?: string): string;
49
+ /**
50
+ * Add a custom locale data source (loaded after Intl, before HTTP).
51
+ */
52
+ addLocaleDataSource(source: CoarLocaleDataSource): void;
53
+ /**
54
+ * Add a custom translation source.
55
+ */
56
+ addTranslationSource(source: CoarTranslationSource): void;
57
+ private loadDataForLanguage;
58
+ private loadLocaleData;
59
+ private loadTranslations;
60
+ }
61
+ //# sourceMappingURL=localization-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization-service.d.ts","sourceRoot":"","sources":["../src/localization-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA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'./types';
3
+ import { CoarLocalizationService } from './localization-service';
4
+ /**
5
+ * Create the Coar Localization Vue plugin.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { createCoarLocalization } from '@cocoar/vue-localization';
10
+ *
11
+ * const app = createApp(App);
12
+ * app.use(createCoarLocalization({
13
+ * defaultLanguage: 'en',
14
+ * i18nUrl: (lang) => `/i18n/${lang}.json`,
15
+ * l10nUrl: (lang) => `/locales/${lang}.json`,
16
+ * }));
17
+ * ```
18
+ */
19
+ export declare function createCoarLocalization(config?: CoarLocalizationConfig): Plugin & {
20
+ service: CoarLocalizationService;
21
+ };
22
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,sBAA2B,GAAG,MAAM,GAAG;IACpF,OAAO,EAAE,uBAAuB,CAAC;CAClC,CAWA"}
@@ -0,0 +1,23 @@
1
+ import { Ref } from 'vue';
2
+ import { CoarTimezoneProvider } from '../types';
3
+ /**
4
+ * Default timezone provider using the browser's Intl API.
5
+ */
6
+ export declare class BrowserTimezoneProvider implements CoarTimezoneProvider {
7
+ getTimezone(): string | null;
8
+ }
9
+ /**
10
+ * Reactive timezone service.
11
+ * Resolves timezone from pluggable providers with browser fallback.
12
+ */
13
+ export declare class CoarTimezoneService {
14
+ private readonly providers;
15
+ private readonly _timezone;
16
+ /** Reactive current timezone (IANA identifier) */
17
+ get timezone(): Readonly<Ref<string>>;
18
+ constructor(customProviders?: CoarTimezoneProvider[]);
19
+ /** Re-resolve the timezone from providers and update the reactive value */
20
+ refresh(): void;
21
+ private resolve;
22
+ }
23
+ //# sourceMappingURL=timezone-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timezone-service.d.ts","sourceRoot":"","sources":["../../src/timezone/timezone-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD;;GAEG;AACH,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,WAAW,IAAI,MAAM,GAAG,IAAI;CAO7B;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IAExC,kDAAkD;IAClD,IAAI,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAEpC;gBAEW,eAAe,GAAE,oBAAoB,EAAO;IAKxD,2EAA2E;IAC3E,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,OAAO;CAOhB"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Date format data for a locale.
3
+ */
4
+ export interface CoarDateFormatData {
5
+ /** Date pattern, e.g. 'dd.mm.yyyy', 'mm/dd/yyyy' */
6
+ pattern: 'dd.mm.yyyy' | 'dd/mm/yyyy' | 'mm/dd/yyyy' | 'yyyy-mm-dd';
7
+ /** First day of week: 0=Sunday, 1=Monday, ..., 6=Saturday */
8
+ firstDayOfWeek: number;
9
+ /** Full month names, e.g. ['January', 'February', ...] */
10
+ monthNames: string[];
11
+ /** Abbreviated month names, e.g. ['Jan', 'Feb', ...] */
12
+ monthNamesShort: string[];
13
+ /** Full day names, e.g. ['Sunday', 'Monday', ...] */
14
+ dayNames: string[];
15
+ /** Abbreviated day names, e.g. ['Sun', 'Mon', ...] */
16
+ dayNamesShort: string[];
17
+ /** AM/PM labels */
18
+ amPm: [string, string];
19
+ }
20
+ /**
21
+ * Number format data for a locale.
22
+ */
23
+ export interface CoarNumberFormatData {
24
+ /** Decimal separator, e.g. '.' or ',' */
25
+ decimal: string;
26
+ /** Grouping separator, e.g. ',' or '.' */
27
+ group: string;
28
+ /** Grouping sizes, e.g. [3] for standard 3-digit grouping */
29
+ grouping: number[];
30
+ }
31
+ /**
32
+ * Currency format data for a locale.
33
+ */
34
+ export interface CoarCurrencyFormatData {
35
+ /** Default currency code, e.g. 'USD', 'EUR' */
36
+ default: string;
37
+ /** Map of currency code → symbol, e.g. { USD: '$', EUR: '€' } */
38
+ symbols: Record<string, string>;
39
+ /** Symbol position relative to the number */
40
+ position: 'before' | 'after';
41
+ /** Whether there's a space between symbol and number */
42
+ spacing: boolean;
43
+ /** Default number of decimal places */
44
+ decimals: number;
45
+ }
46
+ /**
47
+ * Percent format data for a locale.
48
+ */
49
+ export interface CoarPercentFormatData {
50
+ /** Percent symbol */
51
+ symbol: string;
52
+ /** Whether there's a space between number and symbol */
53
+ spacing: boolean;
54
+ /** Default number of decimal places */
55
+ decimals: number;
56
+ }
57
+ /**
58
+ * Complete localization data for a single locale.
59
+ */
60
+ export interface CoarLocalizationData {
61
+ /** Locale code, e.g. 'en', 'de', 'en-US' */
62
+ code: string;
63
+ /** Date formatting data */
64
+ date: CoarDateFormatData;
65
+ /** Number formatting data */
66
+ number: CoarNumberFormatData;
67
+ /** Currency formatting data */
68
+ currency: CoarCurrencyFormatData;
69
+ /** Percent formatting data */
70
+ percent: CoarPercentFormatData;
71
+ }
72
+ /**
73
+ * Configuration for the localization system.
74
+ */
75
+ export interface CoarLocalizationConfig {
76
+ /** Default language to use. Defaults to 'en'. */
77
+ defaultLanguage?: string;
78
+ /** Custom timezone providers (checked before browser default) */
79
+ timezoneProviders?: CoarTimezoneProvider[];
80
+ /** HTTP URL builder for loading locale data. Receives language code, returns URL. */
81
+ l10nUrl?: (language: string) => string;
82
+ /** HTTP URL builder for loading translations. Receives language code, returns URL. */
83
+ i18nUrl?: (language: string) => string;
84
+ }
85
+ /**
86
+ * A pluggable timezone provider.
87
+ * Returns the current IANA timezone identifier, or null if unknown.
88
+ */
89
+ export interface CoarTimezoneProvider {
90
+ /** Returns the current timezone, or null to defer to next provider */
91
+ getTimezone(): string | null;
92
+ }
93
+ /**
94
+ * Nested or flat translation object.
95
+ * Nested objects are flattened to dot-separated keys.
96
+ */
97
+ export interface CoarTranslations {
98
+ [key: string]: string | CoarTranslations;
99
+ }
100
+ /**
101
+ * A source that can load locale data for a given language.
102
+ */
103
+ export interface CoarLocaleDataSource {
104
+ load(language: string): Promise<Partial<CoarLocalizationData> | null>;
105
+ }
106
+ /**
107
+ * A source that can load translations for a given language.
108
+ */
109
+ export interface CoarTranslationSource {
110
+ load(language: string): Promise<CoarTranslations | null>;
111
+ }
112
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,OAAO,EAAE,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;IACnE,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,wDAAwD;IACxD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sDAAsD;IACtD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,mBAAmB;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;A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B;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocoar/vue-localization",
3
- "version": "0.1.0-beta.24",
3
+ "version": "0.1.0-beta.34",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",