@mpfrontend/i18n 0.1.0 → 1.0.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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # @mpfrontend/i18n
2
2
 
3
- Local development package. Runtime: universal. Public API is exported from src/index.ts and compiled
4
- into dist. Nx owns build, typecheck, lint and test targets. Consumer applications install packed artifacts.
5
- See ../../docs/IMPLEMENTATION-STATUS.md for observed evidence and remaining work.
3
+ Part of [MP Frontend](https://github.com/panahister/mpfrontend), released to the public npm registry as one cohort: every `@mpfrontend`
4
+ package at the same exact version. Runtime: universal. Install it through a workspace that `mpfrontend init`
5
+ created, which pins the cohort and binds the scope to the registry in `.npmrc`. [Versioning](https://github.com/panahister/mpfrontend#versioning)
6
+ states the compatibility policy and [Implementation status](https://github.com/panahister/mpfrontend/blob/main/docs/IMPLEMENTATION-STATUS.md) the
7
+ evidence.
6
8
 
7
9
  ## Locales
8
10
 
package/dist/core.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ export declare const catalogs: {
2
+ readonly en: {
3
+ readonly title: "MP Frontend";
4
+ readonly catalog: "Catalog";
5
+ readonly refresh: "Refresh";
6
+ readonly loading: "Loading";
7
+ readonly unavailable: "Backend is unavailable. Try again.";
8
+ readonly empty: "No records found.";
9
+ readonly previous: "Previous";
10
+ readonly next: "Next";
11
+ readonly page: "Page";
12
+ readonly language: "Language";
13
+ readonly brand: "Brand";
14
+ readonly mode: "Appearance";
15
+ readonly light: "Light";
16
+ readonly dark: "Dark";
17
+ readonly system: "System";
18
+ readonly docs: "API documentation";
19
+ readonly source: "Connected to MP Core";
20
+ readonly search: "Search";
21
+ readonly apply: "Apply";
22
+ readonly readOnly: "Read-only public catalog";
23
+ readonly fields: "Fields";
24
+ readonly true: "Yes";
25
+ readonly false: "No";
26
+ readonly detail: "Details";
27
+ readonly back: "Back";
28
+ readonly save: "Save";
29
+ readonly forbidden: "This operation is not permitted.";
30
+ readonly invalid: "Check the permitted fields.";
31
+ readonly remoteChange: "Data changed remotely. Your edits are preserved.";
32
+ readonly skipToContent: "Skip to content";
33
+ readonly navigation: "Main navigation";
34
+ };
35
+ };
36
+ export type MessageKey = keyof typeof catalogs.en;
37
+ declare const neutral: readonly ["loading", "unavailable", "empty", "previous", "next", "page", "language", "brand", "mode", "light", "dark", "system", "search", "apply", "fields", "true", "false", "detail", "back", "save", "refresh", "forbidden", "invalid", "remoteChange", "skipToContent", "navigation"];
38
+ export type CoreMessageKey = (typeof neutral)[number];
39
+ /**
40
+ * The neutral messages of MP Frontend, separate from any product text, in English: the only language that
41
+ * MP Frontend ships. A product's catalog set overrides any of them by defining the same key. A translator
42
+ * looks a message up in the requested locale and then in the set's default locale only, so a product whose
43
+ * default locale is not English never shows this English text. `catalogs` keeps its earlier keys.
44
+ */
45
+ export declare const coreMessages: Readonly<{
46
+ en: Readonly<Record<CoreMessageKey, string>>;
47
+ }>;
48
+ export { createMessages, defineMessages, checkCatalogs, messageArguments, MessageError, type Catalog, type Translation, type MessageArguments, type ArgumentList, type Translate, type Messages, type MessageValue, type ArgumentShape, type CatalogProblem } from './messages.js';
49
+ export type Direction = 'ltr' | 'rtl';
50
+ /** One locale of a registry: its writing direction and, optionally, the digits Intl uses for it. */
51
+ export type LocaleDefinition = Readonly<{
52
+ direction: Direction;
53
+ numberingSystem?: string;
54
+ }>;
55
+ /**
56
+ * The one locale MP Frontend ships: English, left to right. A product registers its own locales, left to
57
+ * right or right to left, in its own repository with `createLocaleRegistry`, never by editing MP Frontend.
58
+ */
59
+ export declare const builtInLocales: {
60
+ readonly en: {
61
+ readonly direction: "ltr";
62
+ };
63
+ };
64
+ /**
65
+ * A locale code (a BCP 47 language tag). MP Frontend enumerates no language: the set of locales is the
66
+ * product's, and `LocaleOf<typeof registry>` is the type of one product registry's codes.
67
+ */
68
+ export type Locale = string;
69
+ export type LocaleOf<R extends LocaleRegistry<string>> = R['locales'][number];
70
+ export type LocaleRegistry<L extends string = string> = Readonly<{
71
+ locales: readonly L[];
72
+ defaultLocale: L;
73
+ /** The registered code itself, or the default for anything else. */
74
+ locale: (value: unknown) => L;
75
+ direction: (value: string) => Direction;
76
+ numberingSystem: (value: string) => string | undefined;
77
+ /** The best registered locale for an Accept-Language header, or the default. */
78
+ negotiate: (header: string | null | undefined) => L;
79
+ }>;
80
+ /**
81
+ * Picks the best of `supported` for an Accept-Language header (RFC 9110 section 12.5.4) by quality, then by
82
+ * an exact range and then by the range's primary language. Malformed or oversized input yields the
83
+ * default; the result is always a member of `supported`, never text taken from the header.
84
+ */
85
+ export declare function negotiateLocale<const L extends string>(header: string | null | undefined, supported: readonly L[], defaultLocale: L): L;
86
+ /**
87
+ * A locale registry configured per app. The default is `defaultLocale`, or `en` when it is not set; a
88
+ * registry without English names its own default, which may be its only locale.
89
+ */
90
+ export declare function createLocaleRegistry<const L extends string>(options: Readonly<{
91
+ locales: Readonly<Record<L, LocaleDefinition>>;
92
+ defaultLocale?: NoInfer<L>;
93
+ }>): LocaleRegistry<L>;
94
+ /** The built-in registry: English only, and the default. A product passes its own registry instead. */
95
+ export declare const locales: Readonly<{
96
+ locales: readonly "en"[];
97
+ defaultLocale: "en";
98
+ /** The registered code itself, or the default for anything else. */
99
+ locale: (value: unknown) => "en";
100
+ direction: (value: string) => Direction;
101
+ numberingSystem: (value: string) => string | undefined;
102
+ /** The best registered locale for an Accept-Language header, or the default. */
103
+ negotiate: (header: string | null | undefined) => "en";
104
+ }>;
105
+ export declare function locale(value: unknown): Locale;
106
+ export declare function direction(value: string): Direction;
107
+ /** The built-in English messages; any other locale falls back, key by key, to English. */
108
+ export declare function translator(value: string): (key: MessageKey) => string;
109
+ /** The text of `true` and `false` from a product's own catalog. */
110
+ export type BooleanLabels = Readonly<{
111
+ true: string;
112
+ false: string;
113
+ }>;
114
+ /**
115
+ * Numbers use the locale's own digits through Intl; strings are never reinterpreted. A boolean is shown
116
+ * with `labels`, the product's own text, or with the built-in English text when no labels are given.
117
+ */
118
+ export declare function formatValue(value: unknown, language: string, registry?: LocaleRegistry, labels?: BooleanLabels): string;
119
+ export declare function formatNumber(value: number, language: string, options?: Intl.NumberFormatOptions, registry?: LocaleRegistry): string;
120
+ export { createPreferenceCookie, type Preference, type PreferenceCookie, type PreferenceCookieContract } from './preferences.js';
package/dist/core.js ADDED
@@ -0,0 +1,126 @@
1
+ export const catalogs = {
2
+ en: { title: 'MP Frontend', catalog: 'Catalog', refresh: 'Refresh', loading: 'Loading', unavailable: 'Backend is unavailable. Try again.', empty: 'No records found.', previous: 'Previous', next: 'Next', page: 'Page', language: 'Language', brand: 'Brand', mode: 'Appearance', light: 'Light', dark: 'Dark', system: 'System', docs: 'API documentation', source: 'Connected to MP Core', search: 'Search', apply: 'Apply', readOnly: 'Read-only public catalog', fields: 'Fields', true: 'Yes', false: 'No', detail: 'Details', back: 'Back', save: 'Save', forbidden: 'This operation is not permitted.', invalid: 'Check the permitted fields.', remoteChange: 'Data changed remotely. Your edits are preserved.', skipToContent: 'Skip to content', navigation: 'Main navigation' },
3
+ };
4
+ const neutral = ['loading', 'unavailable', 'empty', 'previous', 'next', 'page', 'language', 'brand', 'mode', 'light', 'dark', 'system', 'search', 'apply', 'fields', 'true', 'false', 'detail', 'back', 'save', 'refresh', 'forbidden', 'invalid', 'remoteChange', 'skipToContent', 'navigation'];
5
+ /**
6
+ * The neutral messages of MP Frontend, separate from any product text, in English: the only language that
7
+ * MP Frontend ships. A product's catalog set overrides any of them by defining the same key. A translator
8
+ * looks a message up in the requested locale and then in the set's default locale only, so a product whose
9
+ * default locale is not English never shows this English text. `catalogs` keeps its earlier keys.
10
+ */
11
+ export const coreMessages = {
12
+ en: Object.fromEntries(neutral.map(key => [key, catalogs.en[key]])),
13
+ };
14
+ export { createMessages, defineMessages, checkCatalogs, messageArguments, MessageError } from './messages.js';
15
+ /**
16
+ * The one locale MP Frontend ships: English, left to right. A product registers its own locales, left to
17
+ * right or right to left, in its own repository with `createLocaleRegistry`, never by editing MP Frontend.
18
+ */
19
+ export const builtInLocales = {
20
+ en: { direction: 'ltr' },
21
+ };
22
+ const localeCode = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/;
23
+ const languageRange = /^(?:\*|[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8}){0,4})$/;
24
+ const MAX_HEADER = 256, MAX_RANGES = 16;
25
+ /**
26
+ * Picks the best of `supported` for an Accept-Language header (RFC 9110 section 12.5.4) by quality, then by
27
+ * an exact range and then by the range's primary language. Malformed or oversized input yields the
28
+ * default; the result is always a member of `supported`, never text taken from the header.
29
+ */
30
+ export function negotiateLocale(header, supported, defaultLocale) {
31
+ if (!supported.includes(defaultLocale))
32
+ throw new Error('INVALID_DEFAULT_LOCALE');
33
+ if (typeof header !== 'string' || header.length > MAX_HEADER)
34
+ return defaultLocale;
35
+ const parts = header.split(',');
36
+ if (parts.length > MAX_RANGES)
37
+ return defaultLocale;
38
+ const ranges = [];
39
+ for (const [order, part] of parts.entries()) {
40
+ const [rawRange, ...parameters] = part.split(';').map(value => value.trim());
41
+ if (!rawRange || !languageRange.test(rawRange))
42
+ continue;
43
+ let quality = 1;
44
+ for (const parameter of parameters) {
45
+ const match = /^q=(0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.exec(parameter);
46
+ if (!match) {
47
+ quality = -1;
48
+ break;
49
+ }
50
+ quality = Number(match[1]);
51
+ }
52
+ if (quality > 0)
53
+ ranges.push({ range: rawRange.toLowerCase(), quality, order });
54
+ }
55
+ ranges.sort((left, right) => right.quality - left.quality || left.order - right.order);
56
+ const lower = supported.map(code => code.toLowerCase());
57
+ for (const { range } of ranges) {
58
+ if (range === '*')
59
+ return defaultLocale;
60
+ const exact = lower.indexOf(range);
61
+ if (exact >= 0)
62
+ return supported[exact];
63
+ const primary = lower.indexOf(range.split('-')[0]);
64
+ if (primary >= 0)
65
+ return supported[primary];
66
+ }
67
+ return defaultLocale;
68
+ }
69
+ /**
70
+ * A locale registry configured per app. The default is `defaultLocale`, or `en` when it is not set; a
71
+ * registry without English names its own default, which may be its only locale.
72
+ */
73
+ export function createLocaleRegistry(options) {
74
+ const codes = Object.keys(options.locales);
75
+ if (!codes.length)
76
+ throw new Error('EMPTY_LOCALE_REGISTRY');
77
+ for (const code of codes) {
78
+ const definition = options.locales[code];
79
+ if (!localeCode.test(code) || (definition.direction !== 'ltr' && definition.direction !== 'rtl'))
80
+ throw new Error('INVALID_LOCALE_DEFINITION');
81
+ if (definition.numberingSystem !== undefined && !/^[a-z]{3,8}$/.test(definition.numberingSystem))
82
+ throw new Error('INVALID_LOCALE_DEFINITION');
83
+ }
84
+ const defaultLocale = options.defaultLocale ?? 'en';
85
+ if (!codes.includes(defaultLocale))
86
+ throw new Error('INVALID_DEFAULT_LOCALE');
87
+ const known = (value) => typeof value === 'string' && codes.includes(value);
88
+ return Object.freeze({
89
+ locales: Object.freeze([...codes]),
90
+ defaultLocale,
91
+ locale: (value) => known(value) ? value : defaultLocale,
92
+ direction: (value) => (known(value) ? options.locales[value] : options.locales[defaultLocale]).direction,
93
+ numberingSystem: (value) => (known(value) ? options.locales[value] : options.locales[defaultLocale]).numberingSystem,
94
+ negotiate: (header) => negotiateLocale(header, codes, defaultLocale),
95
+ });
96
+ }
97
+ /** The built-in registry: English only, and the default. A product passes its own registry instead. */
98
+ export const locales = createLocaleRegistry({ locales: builtInLocales });
99
+ export function locale(value) { return locales.locale(value); }
100
+ export function direction(value) { return locales.direction(value); }
101
+ /** The built-in English messages; any other locale falls back, key by key, to English. */
102
+ export function translator(value) {
103
+ const own = catalogs[value];
104
+ return key => own?.[key] ?? catalogs.en[key];
105
+ }
106
+ /**
107
+ * Numbers use the locale's own digits through Intl; strings are never reinterpreted. A boolean is shown
108
+ * with `labels`, the product's own text, or with the built-in English text when no labels are given.
109
+ */
110
+ export function formatValue(value, language, registry = locales, labels) {
111
+ if (value === null || value === undefined)
112
+ return '—';
113
+ if (typeof value === 'boolean')
114
+ return labels ? (value ? labels.true : labels.false) : translator(language)(value ? 'true' : 'false');
115
+ if (typeof value === 'number')
116
+ return formatNumber(value, language, {}, registry);
117
+ if (typeof value === 'object')
118
+ return JSON.stringify(value);
119
+ return String(value);
120
+ }
121
+ export function formatNumber(value, language, options = {}, registry = locales) {
122
+ const numberingSystem = registry.numberingSystem(language);
123
+ return new Intl.NumberFormat(registry.locale(language), { maximumFractionDigits: 8, ...(numberingSystem ? { numberingSystem } : {}), ...options }).format(value);
124
+ }
125
+ export { createPreferenceCookie } from './preferences.js';
126
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,EAAE,KAAK,EAAC,aAAa,EAAE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,oCAAoC,EAAE,KAAK,EAAC,mBAAmB,EAAE,QAAQ,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,EAAC,UAAU,EAAE,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,YAAY,EAAE,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,mBAAmB,EAAE,MAAM,EAAC,sBAAsB,EAAE,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,0BAA0B,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,KAAK,EAAE,KAAK,EAAC,IAAI,EAAE,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,SAAS,EAAC,kCAAkC,EAAE,OAAO,EAAC,6BAA6B,EAAE,YAAY,EAAC,kDAAkD,EAAE,aAAa,EAAC,iBAAiB,EAAE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AAe,GAAG,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC3D,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnK,CAAC;AACD,OAAO,EAAE,sBAAsB,EAAyE,MAAM,kBAAkB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,120 +1 @@
1
- export declare const catalogs: {
2
- readonly en: {
3
- readonly title: "MP Frontend";
4
- readonly catalog: "Catalog";
5
- readonly refresh: "Refresh";
6
- readonly loading: "Loading";
7
- readonly unavailable: "Backend is unavailable. Try again.";
8
- readonly empty: "No records found.";
9
- readonly previous: "Previous";
10
- readonly next: "Next";
11
- readonly page: "Page";
12
- readonly language: "Language";
13
- readonly brand: "Brand";
14
- readonly mode: "Appearance";
15
- readonly light: "Light";
16
- readonly dark: "Dark";
17
- readonly system: "System";
18
- readonly docs: "API documentation";
19
- readonly source: "Connected to MP Core";
20
- readonly search: "Search";
21
- readonly apply: "Apply";
22
- readonly readOnly: "Read-only public catalog";
23
- readonly fields: "Fields";
24
- readonly true: "Yes";
25
- readonly false: "No";
26
- readonly detail: "Details";
27
- readonly back: "Back";
28
- readonly save: "Save";
29
- readonly forbidden: "This operation is not permitted.";
30
- readonly invalid: "Check the permitted fields.";
31
- readonly remoteChange: "Data changed remotely. Your edits are preserved.";
32
- readonly skipToContent: "Skip to content";
33
- readonly navigation: "Main navigation";
34
- };
35
- };
36
- export type MessageKey = keyof typeof catalogs.en;
37
- declare const neutral: readonly ["loading", "unavailable", "empty", "previous", "next", "page", "language", "brand", "mode", "light", "dark", "system", "search", "apply", "fields", "true", "false", "detail", "back", "save", "refresh", "forbidden", "invalid", "remoteChange", "skipToContent", "navigation"];
38
- export type CoreMessageKey = (typeof neutral)[number];
39
- /**
40
- * The neutral messages of MP Frontend, separate from any product text, in English: the only language that
41
- * MP Frontend ships. A product's catalog set overrides any of them by defining the same key. A translator
42
- * looks a message up in the requested locale and then in the set's default locale only, so a product whose
43
- * default locale is not English never shows this English text. `catalogs` keeps its earlier keys.
44
- */
45
- export declare const coreMessages: Readonly<{
46
- en: Readonly<Record<CoreMessageKey, string>>;
47
- }>;
48
- export { createMessages, defineMessages, checkCatalogs, messageArguments, MessageError, type Catalog, type Translation, type MessageArguments, type ArgumentList, type Translate, type Messages, type MessageValue, type ArgumentShape, type CatalogProblem } from './messages.js';
49
- export type Direction = 'ltr' | 'rtl';
50
- /** One locale of a registry: its writing direction and, optionally, the digits Intl uses for it. */
51
- export type LocaleDefinition = Readonly<{
52
- direction: Direction;
53
- numberingSystem?: string;
54
- }>;
55
- /**
56
- * The one locale MP Frontend ships: English, left to right. A product registers its own locales, left to
57
- * right or right to left, in its own repository with `createLocaleRegistry`, never by editing MP Frontend.
58
- */
59
- export declare const builtInLocales: {
60
- readonly en: {
61
- readonly direction: "ltr";
62
- };
63
- };
64
- /**
65
- * A locale code (a BCP 47 language tag). MP Frontend enumerates no language: the set of locales is the
66
- * product's, and `LocaleOf<typeof registry>` is the type of one product registry's codes.
67
- */
68
- export type Locale = string;
69
- export type LocaleOf<R extends LocaleRegistry<string>> = R['locales'][number];
70
- export type LocaleRegistry<L extends string = string> = Readonly<{
71
- locales: readonly L[];
72
- defaultLocale: L;
73
- /** The registered code itself, or the default for anything else. */
74
- locale: (value: unknown) => L;
75
- direction: (value: string) => Direction;
76
- numberingSystem: (value: string) => string | undefined;
77
- /** The best registered locale for an Accept-Language header, or the default. */
78
- negotiate: (header: string | null | undefined) => L;
79
- }>;
80
- /**
81
- * Picks the best of `supported` for an Accept-Language header (RFC 9110 section 12.5.4) by quality, then by
82
- * an exact range and then by the range's primary language. Malformed or oversized input yields the
83
- * default; the result is always a member of `supported`, never text taken from the header.
84
- */
85
- export declare function negotiateLocale<const L extends string>(header: string | null | undefined, supported: readonly L[], defaultLocale: L): L;
86
- /**
87
- * A locale registry configured per app. The default is `defaultLocale`, or `en` when it is not set; a
88
- * registry without English names its own default, which may be its only locale.
89
- */
90
- export declare function createLocaleRegistry<const L extends string>(options: Readonly<{
91
- locales: Readonly<Record<L, LocaleDefinition>>;
92
- defaultLocale?: NoInfer<L>;
93
- }>): LocaleRegistry<L>;
94
- /** The built-in registry: English only, and the default. A product passes its own registry instead. */
95
- export declare const locales: Readonly<{
96
- locales: readonly "en"[];
97
- defaultLocale: "en";
98
- /** The registered code itself, or the default for anything else. */
99
- locale: (value: unknown) => "en";
100
- direction: (value: string) => Direction;
101
- numberingSystem: (value: string) => string | undefined;
102
- /** The best registered locale for an Accept-Language header, or the default. */
103
- negotiate: (header: string | null | undefined) => "en";
104
- }>;
105
- export declare function locale(value: unknown): Locale;
106
- export declare function direction(value: string): Direction;
107
- /** The built-in English messages; any other locale falls back, key by key, to English. */
108
- export declare function translator(value: string): (key: MessageKey) => string;
109
- /** The text of `true` and `false` from a product's own catalog. */
110
- export type BooleanLabels = Readonly<{
111
- true: string;
112
- false: string;
113
- }>;
114
- /**
115
- * Numbers use the locale's own digits through Intl; strings are never reinterpreted. A boolean is shown
116
- * with `labels`, the product's own text, or with the built-in English text when no labels are given.
117
- */
118
- export declare function formatValue(value: unknown, language: string, registry?: LocaleRegistry, labels?: BooleanLabels): string;
119
- export declare function formatNumber(value: number, language: string, options?: Intl.NumberFormatOptions, registry?: LocaleRegistry): string;
120
- export { createPreferenceCookie, type Preference, type PreferenceCookie, type PreferenceCookieContract } from './preferences.js';
1
+ export { type ArgumentList, type ArgumentShape, type BooleanLabels, type Catalog, type CatalogProblem, catalogs, checkCatalogs, type CoreMessageKey, coreMessages, createLocaleRegistry, createMessages, createPreferenceCookie, defineMessages, direction, type Direction, formatNumber, formatValue, locale, type Locale, type LocaleDefinition, type LocaleOf, type LocaleRegistry, locales, messageArguments, type MessageArguments, type MessageKey, type Messages, negotiateLocale, type Preference, type PreferenceCookie, type PreferenceCookieContract, type Translate, type Translation, translator, } from './core.js';
package/dist/index.js CHANGED
@@ -1,126 +1,2 @@
1
- export const catalogs = {
2
- en: { title: 'MP Frontend', catalog: 'Catalog', refresh: 'Refresh', loading: 'Loading', unavailable: 'Backend is unavailable. Try again.', empty: 'No records found.', previous: 'Previous', next: 'Next', page: 'Page', language: 'Language', brand: 'Brand', mode: 'Appearance', light: 'Light', dark: 'Dark', system: 'System', docs: 'API documentation', source: 'Connected to MP Core', search: 'Search', apply: 'Apply', readOnly: 'Read-only public catalog', fields: 'Fields', true: 'Yes', false: 'No', detail: 'Details', back: 'Back', save: 'Save', forbidden: 'This operation is not permitted.', invalid: 'Check the permitted fields.', remoteChange: 'Data changed remotely. Your edits are preserved.', skipToContent: 'Skip to content', navigation: 'Main navigation' },
3
- };
4
- const neutral = ['loading', 'unavailable', 'empty', 'previous', 'next', 'page', 'language', 'brand', 'mode', 'light', 'dark', 'system', 'search', 'apply', 'fields', 'true', 'false', 'detail', 'back', 'save', 'refresh', 'forbidden', 'invalid', 'remoteChange', 'skipToContent', 'navigation'];
5
- /**
6
- * The neutral messages of MP Frontend, separate from any product text, in English: the only language that
7
- * MP Frontend ships. A product's catalog set overrides any of them by defining the same key. A translator
8
- * looks a message up in the requested locale and then in the set's default locale only, so a product whose
9
- * default locale is not English never shows this English text. `catalogs` keeps its earlier keys.
10
- */
11
- export const coreMessages = {
12
- en: Object.fromEntries(neutral.map(key => [key, catalogs.en[key]])),
13
- };
14
- export { createMessages, defineMessages, checkCatalogs, messageArguments, MessageError } from './messages.js';
15
- /**
16
- * The one locale MP Frontend ships: English, left to right. A product registers its own locales, left to
17
- * right or right to left, in its own repository with `createLocaleRegistry`, never by editing MP Frontend.
18
- */
19
- export const builtInLocales = {
20
- en: { direction: 'ltr' },
21
- };
22
- const localeCode = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/;
23
- const languageRange = /^(?:\*|[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8}){0,4})$/;
24
- const MAX_HEADER = 256, MAX_RANGES = 16;
25
- /**
26
- * Picks the best of `supported` for an Accept-Language header (RFC 9110 section 12.5.4) by quality, then by
27
- * an exact range and then by the range's primary language. Malformed or oversized input yields the
28
- * default; the result is always a member of `supported`, never text taken from the header.
29
- */
30
- export function negotiateLocale(header, supported, defaultLocale) {
31
- if (!supported.includes(defaultLocale))
32
- throw new Error('INVALID_DEFAULT_LOCALE');
33
- if (typeof header !== 'string' || header.length > MAX_HEADER)
34
- return defaultLocale;
35
- const parts = header.split(',');
36
- if (parts.length > MAX_RANGES)
37
- return defaultLocale;
38
- const ranges = [];
39
- for (const [order, part] of parts.entries()) {
40
- const [rawRange, ...parameters] = part.split(';').map(value => value.trim());
41
- if (!rawRange || !languageRange.test(rawRange))
42
- continue;
43
- let quality = 1;
44
- for (const parameter of parameters) {
45
- const match = /^q=(0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.exec(parameter);
46
- if (!match) {
47
- quality = -1;
48
- break;
49
- }
50
- quality = Number(match[1]);
51
- }
52
- if (quality > 0)
53
- ranges.push({ range: rawRange.toLowerCase(), quality, order });
54
- }
55
- ranges.sort((left, right) => right.quality - left.quality || left.order - right.order);
56
- const lower = supported.map(code => code.toLowerCase());
57
- for (const { range } of ranges) {
58
- if (range === '*')
59
- return defaultLocale;
60
- const exact = lower.indexOf(range);
61
- if (exact >= 0)
62
- return supported[exact];
63
- const primary = lower.indexOf(range.split('-')[0]);
64
- if (primary >= 0)
65
- return supported[primary];
66
- }
67
- return defaultLocale;
68
- }
69
- /**
70
- * A locale registry configured per app. The default is `defaultLocale`, or `en` when it is not set; a
71
- * registry without English names its own default, which may be its only locale.
72
- */
73
- export function createLocaleRegistry(options) {
74
- const codes = Object.keys(options.locales);
75
- if (!codes.length)
76
- throw new Error('EMPTY_LOCALE_REGISTRY');
77
- for (const code of codes) {
78
- const definition = options.locales[code];
79
- if (!localeCode.test(code) || (definition.direction !== 'ltr' && definition.direction !== 'rtl'))
80
- throw new Error('INVALID_LOCALE_DEFINITION');
81
- if (definition.numberingSystem !== undefined && !/^[a-z]{3,8}$/.test(definition.numberingSystem))
82
- throw new Error('INVALID_LOCALE_DEFINITION');
83
- }
84
- const defaultLocale = options.defaultLocale ?? 'en';
85
- if (!codes.includes(defaultLocale))
86
- throw new Error('INVALID_DEFAULT_LOCALE');
87
- const known = (value) => typeof value === 'string' && codes.includes(value);
88
- return Object.freeze({
89
- locales: Object.freeze([...codes]),
90
- defaultLocale,
91
- locale: (value) => known(value) ? value : defaultLocale,
92
- direction: (value) => (known(value) ? options.locales[value] : options.locales[defaultLocale]).direction,
93
- numberingSystem: (value) => (known(value) ? options.locales[value] : options.locales[defaultLocale]).numberingSystem,
94
- negotiate: (header) => negotiateLocale(header, codes, defaultLocale),
95
- });
96
- }
97
- /** The built-in registry: English only, and the default. A product passes its own registry instead. */
98
- export const locales = createLocaleRegistry({ locales: builtInLocales });
99
- export function locale(value) { return locales.locale(value); }
100
- export function direction(value) { return locales.direction(value); }
101
- /** The built-in English messages; any other locale falls back, key by key, to English. */
102
- export function translator(value) {
103
- const own = catalogs[value];
104
- return key => own?.[key] ?? catalogs.en[key];
105
- }
106
- /**
107
- * Numbers use the locale's own digits through Intl; strings are never reinterpreted. A boolean is shown
108
- * with `labels`, the product's own text, or with the built-in English text when no labels are given.
109
- */
110
- export function formatValue(value, language, registry = locales, labels) {
111
- if (value === null || value === undefined)
112
- return '—';
113
- if (typeof value === 'boolean')
114
- return labels ? (value ? labels.true : labels.false) : translator(language)(value ? 'true' : 'false');
115
- if (typeof value === 'number')
116
- return formatNumber(value, language, {}, registry);
117
- if (typeof value === 'object')
118
- return JSON.stringify(value);
119
- return String(value);
120
- }
121
- export function formatNumber(value, language, options = {}, registry = locales) {
122
- const numberingSystem = registry.numberingSystem(language);
123
- return new Intl.NumberFormat(registry.locale(language), { maximumFractionDigits: 8, ...(numberingSystem ? { numberingSystem } : {}), ...options }).format(value);
124
- }
125
- export { createPreferenceCookie } from './preferences.js';
1
+ export { catalogs, checkCatalogs, coreMessages, createLocaleRegistry, createMessages, createPreferenceCookie, defineMessages, direction, formatNumber, formatValue, locale, locales, messageArguments, negotiateLocale, translator, } from './core.js';
126
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,EAAE,KAAK,EAAC,aAAa,EAAE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,oCAAoC,EAAE,KAAK,EAAC,mBAAmB,EAAE,QAAQ,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,EAAC,UAAU,EAAE,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,YAAY,EAAE,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,mBAAmB,EAAE,MAAM,EAAC,sBAAsB,EAAE,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,0BAA0B,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,KAAK,EAAE,KAAK,EAAC,IAAI,EAAE,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,SAAS,EAAC,kCAAkC,EAAE,OAAO,EAAC,6BAA6B,EAAE,YAAY,EAAC,kDAAkD,EAAE,aAAa,EAAC,iBAAiB,EAAE,UAAU,EAAC,iBAAiB,EAAE;CACptB,CAAC;AAEX,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,aA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C,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnK,CAAC;AACD,OAAO,EAAE,sBAAsB,EAAyE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,QAAQ,EACR,aAAa,EAEb,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,SAAS,EAET,YAAY,EACZ,WAAW,EACX,MAAM,EAKN,OAAO,EACP,gBAAgB,EAIhB,eAAe,EAMf,UAAU,GACX,MAAM,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { builtInLocales, MessageError, type MessageValue } from './core.js';
@@ -0,0 +1,3 @@
1
+ // For the cohort's own packages: outside the compatibility guarantee (README "Versioning").
2
+ export { builtInLocales, MessageError } from './core.js';
3
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAC,cAAc,EAAC,YAAY,EAAmB,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpfrontend/i18n",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,6 +14,10 @@
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
+ },
18
+ "./internal": {
19
+ "types": "./dist/internal.d.ts",
20
+ "import": "./dist/internal.js"
17
21
  }
18
22
  },
19
23
  "files": [