@newheap/platform-ai-chat 0.11.0 → 0.12.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
@@ -453,7 +453,9 @@ use small built-in outline glyphs:
453
453
  ## Translations
454
454
 
455
455
  All keys live under `nh-assistant.`. With `translations: 'bundled'` the library
456
- merges its `en` and `nl` texts whenever the host loads a language; other
456
+ merges its `en` and `nl` texts whenever the host loads a language. A regional
457
+ language such as `nl-NL`, `nl-BE` or `en-GB` receives the texts of its base
458
+ language, so a host with regional languages needs no merge of its own; other
457
459
  languages receive English. Keys the host defines under `nh-assistant.` win, so a
458
460
  host adds only what the server decides:
459
461
 
@@ -1006,7 +1006,8 @@ var en = {
1006
1006
  trigger: "by its trigger",
1007
1007
  rules: "by the rules",
1008
1008
  triage: "by triage",
1009
- model: "by the model"
1009
+ model: "by the model",
1010
+ "follow-up": "as the follow-up of a decision"
1010
1011
  },
1011
1012
  "tool-calls": "{{count}} tool calls",
1012
1013
  tokens: "{{count}} tokens",
@@ -1957,7 +1958,8 @@ var nl = {
1957
1958
  trigger: "door de trigger",
1958
1959
  rules: "door de regels",
1959
1960
  triage: "door triage",
1960
- model: "door het model"
1961
+ model: "door het model",
1962
+ "follow-up": "als vervolg op een besluit"
1961
1963
  },
1962
1964
  "tool-calls": "{{count}} tool-aanroepen",
1963
1965
  tokens: "{{count}} tokens",
@@ -2013,6 +2015,18 @@ function mergeTrees(base, override) {
2013
2015
  }
2014
2016
  return result;
2015
2017
  }
2018
+ /**
2019
+ * The bundle of a language: its own, else that of its base language, so a regional tag such as
2020
+ * `nl-NL`, `nl_BE` or `en-GB` gets the `nl` or `en` texts, else English.
2021
+ */
2022
+ function bundleOf(language) {
2023
+ for (const candidate of [language, language.split(/[-_]/)[0]].map(tag => tag.toLowerCase())) {
2024
+ if (Object.hasOwn(NH_ASSISTANT_TRANSLATIONS, candidate)) {
2025
+ return NH_ASSISTANT_TRANSLATIONS[candidate];
2026
+ }
2027
+ }
2028
+ return NH_ASSISTANT_TRANSLATIONS.en;
2029
+ }
2016
2030
  function hasAllKeys(bundle, candidate) {
2017
2031
  if (!isTree(candidate)) {
2018
2032
  return false;
@@ -2023,7 +2037,8 @@ function hasAllKeys(bundle, candidate) {
2023
2037
  * Merges the bundled texts into `TranslateService` whenever the host loads or replaces a
2024
2038
  * language. Host loaders never lose the library texts, the library never pre-empts the
2025
2039
  * host loader, and keys the host defines under `nh-assistant.` (agent names, overrides)
2026
- * win over the bundle. Languages without a bundle receive the English texts.
2040
+ * win over the bundle. A regional language such as `nl-NL` receives the texts of its base
2041
+ * language; languages without a bundle receive the English texts.
2027
2042
  */
2028
2043
  class NhAssistantTranslationMerger {
2029
2044
  constructor() {
@@ -2051,8 +2066,7 @@ class NhAssistantTranslationMerger {
2051
2066
  }
2052
2067
  }
2053
2068
  ensure(language, existing) {
2054
- const bundle = (NH_ASSISTANT_TRANSLATIONS[language] ?? NH_ASSISTANT_TRANSLATIONS.en);
2055
- const bundleRoot = bundle[rootKey];
2069
+ const bundleRoot = bundleOf(language)[rootKey];
2056
2070
  if (hasAllKeys(bundleRoot, existing)) {
2057
2071
  return;
2058
2072
  }