@byline/i18n 4.11.2 → 4.13.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
@@ -17,7 +17,7 @@ The package bundles every official Byline admin translation as a JSON file under
17
17
  ## Three entry points
18
18
 
19
19
  ```ts
20
- import { mergeTranslations, createFormatter, resolveInterfaceLocale } from '@byline/i18n'
20
+ import { mergeTranslations, createFormatter, resolveAdminLocale } from '@byline/i18n'
21
21
  import { I18nProvider, useTranslation, LanguageMenu } from '@byline/i18n/react'
22
22
  import { adminTranslations, en } from '@byline/i18n/admin'
23
23
  ```
@@ -30,19 +30,19 @@ import { adminTranslations, en } from '@byline/i18n/admin'
30
30
 
31
31
  ```ts
32
32
  // apps/your-app/byline/admin.config.ts
33
- import { defineClientConfig } from '@byline/core'
33
+ import { defineAdminConfig } from '@byline/core'
34
34
  import { adminTranslations } from '@byline/i18n/admin'
35
35
 
36
- defineClientConfig({
36
+ defineAdminConfig({
37
37
  i18n: {
38
- interface: {
38
+ admin: {
39
39
  defaultLocale: 'en',
40
40
  locales: ['en'],
41
41
  },
42
42
  // … content locales as before
43
43
  translations: adminTranslations({ locales: ['en'] }),
44
44
  },
45
- // … the rest of your client config
45
+ // … the rest of your admin config
46
46
  })
47
47
  ```
48
48
 
@@ -52,7 +52,7 @@ defineClientConfig({
52
52
  import { adminTranslations } from '@byline/i18n/admin'
53
53
 
54
54
  i18n: {
55
- interface: { defaultLocale: 'en', locales: ['en', 'fr'] },
55
+ admin: { defaultLocale: 'en', locales: ['en', 'fr'] },
56
56
  translations: adminTranslations({ locales: ['en', 'fr'] }),
57
57
  }
58
58
  ```
@@ -63,7 +63,7 @@ The set of bundled locales is exported as `bundledLocales` for hosts that want t
63
63
  import { adminTranslations, bundledLocales } from '@byline/i18n/admin'
64
64
 
65
65
  i18n: {
66
- interface: { defaultLocale: 'en', locales: [...bundledLocales] },
66
+ admin: { defaultLocale: 'en', locales: [...bundledLocales] },
67
67
  translations: adminTranslations({ locales: bundledLocales }),
68
68
  }
69
69
  ```
@@ -72,7 +72,7 @@ i18n: {
72
72
 
73
73
  ## Plugin contributions
74
74
 
75
- A plugin (richtext extension, custom field, AI tool, …) ships its own JSON files inside its own package and exposes a factory matching `adminTranslations`'s shape — takes `{ locales }`, returns a `TranslationBundle` for the plugin's own namespace. The host merges them in `defineClientConfig`:
75
+ A plugin (richtext extension, custom field, AI tool, …) ships its own JSON files inside its own package and exposes a factory matching `adminTranslations`'s shape — takes `{ locales }`, returns a `TranslationBundle` for the plugin's own namespace. The host merges them in `defineAdminConfig`:
76
76
 
77
77
  ```ts
78
78
  import { mergeTranslations } from '@byline/i18n'
@@ -80,7 +80,7 @@ import { adminTranslations } from '@byline/i18n/admin'
80
80
  import { aiTranslations } from '@byline/ai/i18n'
81
81
 
82
82
  i18n: {
83
- interface: { defaultLocale: 'en', locales: ['en', 'fr'] },
83
+ admin: { defaultLocale: 'en', locales: ['en', 'fr'] },
84
84
  translations: mergeTranslations(
85
85
  adminTranslations({ locales: ['en', 'fr'] }),
86
86
  aiTranslations({ locales: ['en', 'fr'] }),
@@ -88,7 +88,7 @@ i18n: {
88
88
  }
89
89
  ```
90
90
 
91
- A plugin that ships a locale the host hasn't enabled is harmless — the plugin's factory simply returns nothing for that code, the merge produces an empty entry for it, and the boot validator gates against `i18n.interface.locales` anyway.
91
+ A plugin that ships a locale the host hasn't enabled is harmless — the plugin's factory simply returns nothing for that code, the merge produces an empty entry for it, and the boot validator gates against `i18n.admin.locales` anyway.
92
92
 
93
93
  `mergeTranslations` is associative + deterministic; later sources override earlier ones at the `(locale, namespace, key)` grain, and a `MergeOptions.onCollision` callback is available for surfacing conflicts during development.
94
94
 
@@ -138,12 +138,12 @@ In a TanStack Start host, `resolveServerTranslator(namespace)` (provided by `@by
138
138
 
139
139
  ## Locale resolution cascade
140
140
 
141
- `resolveInterfaceLocale` is the same pure cascade run on client and server, so SSR and hydration produce the same answer:
141
+ `resolveAdminLocale` is the same pure cascade run on client and server, so SSR and hydration produce the same answer:
142
142
 
143
143
  ```ts
144
- import { resolveInterfaceLocale } from '@byline/i18n'
144
+ import { resolveAdminLocale } from '@byline/i18n'
145
145
 
146
- const activeLocale = resolveInterfaceLocale({
146
+ const activeLocale = resolveAdminLocale({
147
147
  locales: ['en', 'fr'],
148
148
  defaultLocale: 'en',
149
149
  preferred: actor?.admin_user?.preferred_locale,
@@ -14,10 +14,11 @@ declare const de: NamespaceTranslations;
14
14
  declare const it: NamespaceTranslations;
15
15
  declare const zhCN: NamespaceTranslations;
16
16
  declare const ko: NamespaceTranslations;
17
+ declare const th: NamespaceTranslations;
17
18
  /** Locale codes for which a bundled translation ships in-package. */
18
19
  export declare const bundledLocales: readonly LocaleCode[];
19
20
  /** Re-exported as typed consts for plugin authors who want the literal-key autocomplete. */
20
- export { de, en, es, fr, it, ko, zhCN };
21
+ export { de, en, es, fr, it, ko, th, zhCN };
21
22
  export type AdminNamespaceTranslations = typeof enJson;
22
23
  export interface AdminTranslationsOptions {
23
24
  /**
@@ -36,9 +37,9 @@ export interface AdminTranslationsOptions {
36
37
  * ```ts
37
38
  * import { adminTranslations } from '@byline/i18n/admin'
38
39
  *
39
- * defineClientConfig({
40
+ * defineAdminConfig({
40
41
  * i18n: {
41
- * interface: { defaultLocale: 'en', locales: ['en', 'fr'] },
42
+ * admin: { defaultLocale: 'en', locales: ['en', 'fr'] },
42
43
  * translations: adminTranslations({ locales: ['en', 'fr'] }),
43
44
  * },
44
45
  * })
@@ -5,6 +5,7 @@ import es from "./es.js";
5
5
  import fr from "./fr.js";
6
6
  import it from "./it.js";
7
7
  import ko from "./ko.js";
8
+ import th from "./th.js";
8
9
  import zh_CN from "./zh-CN.js";
9
10
  const admin_en = en;
10
11
  const admin_fr = fr;
@@ -13,6 +14,7 @@ const admin_de = de;
13
14
  const admin_it = it;
14
15
  const zhCN = zh_CN;
15
16
  const admin_ko = ko;
17
+ const admin_th = th;
16
18
  const BUNDLES = {
17
19
  en: admin_en,
18
20
  fr: admin_fr,
@@ -20,7 +22,8 @@ const BUNDLES = {
20
22
  de: admin_de,
21
23
  it: admin_it,
22
24
  'zh-CN': zhCN,
23
- ko: admin_ko
25
+ ko: admin_ko,
26
+ th: admin_th
24
27
  };
25
28
  const bundledLocales = Object.freeze(Object.keys(BUNDLES));
26
29
  function adminTranslations(options = {}) {
@@ -39,4 +42,4 @@ function adminTranslations(options = {}) {
39
42
  }
40
43
  return mergeTranslations(...partials);
41
44
  }
42
- export { adminTranslations, admin_de as de, admin_en as en, admin_es as es, admin_fr as fr, admin_it as it, admin_ko as ko, bundledLocales, zhCN };
45
+ export { adminTranslations, admin_de as de, admin_en as en, admin_es as es, admin_fr as fr, admin_it as it, admin_ko as ko, admin_th as th, bundledLocales, zhCN };