@aidc-toolkit/core 0.9.6-beta → 0.9.7-beta

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/dist/index.cjs CHANGED
@@ -50,6 +50,9 @@ var I18NEnvironment = /* @__PURE__ */ ((I18NEnvironment2) => {
50
50
  I18NEnvironment2[I18NEnvironment2["Browser"] = 2] = "Browser";
51
51
  return I18NEnvironment2;
52
52
  })(I18NEnvironment || {});
53
+ function toLowerCase(s) {
54
+ return s.split(" ").map((word) => /[a-z]/.test(word) ? word.toLowerCase() : word).join(" ");
55
+ }
53
56
  async function i18nInit(environment, debug = false) {
54
57
  let initialized;
55
58
  if (pendingResourceBundles !== void 0) {
@@ -72,7 +75,7 @@ async function i18nInit(environment, debug = false) {
72
75
  debug,
73
76
  resources: {}
74
77
  }).then(() => {
75
- import_i18next.default.services.formatter?.add("toLowerCase", (value) => typeof value === "string" ? value.toLowerCase() : String(value));
78
+ import_i18next.default.services.formatter?.add("toLowerCase", (value) => typeof value === "string" ? toLowerCase(value) : String(value));
76
79
  for (const initResourceBundle of initResourceBundles) {
77
80
  i18nAddResourceBundle(initResourceBundle.lng, initResourceBundle.ns, initResourceBundle.resources);
78
81
  }
package/dist/index.js CHANGED
@@ -10,6 +10,9 @@ var I18NEnvironment = /* @__PURE__ */ ((I18NEnvironment2) => {
10
10
  I18NEnvironment2[I18NEnvironment2["Browser"] = 2] = "Browser";
11
11
  return I18NEnvironment2;
12
12
  })(I18NEnvironment || {});
13
+ function toLowerCase(s) {
14
+ return s.split(" ").map((word) => /[a-z]/.test(word) ? word.toLowerCase() : word).join(" ");
15
+ }
13
16
  async function i18nInit(environment, debug = false) {
14
17
  let initialized;
15
18
  if (pendingResourceBundles !== void 0) {
@@ -32,7 +35,7 @@ async function i18nInit(environment, debug = false) {
32
35
  debug,
33
36
  resources: {}
34
37
  }).then(() => {
35
- i18next.services.formatter?.add("toLowerCase", (value) => typeof value === "string" ? value.toLowerCase() : String(value));
38
+ i18next.services.formatter?.add("toLowerCase", (value) => typeof value === "string" ? toLowerCase(value) : String(value));
36
39
  for (const initResourceBundle of initResourceBundles) {
37
40
  i18nAddResourceBundle(initResourceBundle.lng, initResourceBundle.ns, initResourceBundle.resources);
38
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/core",
3
- "version": "0.9.6-beta",
3
+ "version": "0.9.7-beta",
4
4
  "description": "Core functionality for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,16 +24,16 @@
24
24
  "build-doc": "npm run build && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap"
25
25
  },
26
26
  "devDependencies": {
27
- "@aidc-toolkit/dev": "^0.9.6-beta",
27
+ "@aidc-toolkit/dev": "^0.9.7-beta",
28
28
  "eslint": "^9.16.0",
29
29
  "ts-node": "^10.9.2",
30
30
  "tsup": "^8.3.5",
31
31
  "typescript": "^5.7.2"
32
32
  },
33
33
  "dependencies": {
34
- "@rollup/rollup-linux-x64-gnu": "^4.28.0",
34
+ "@rollup/rollup-linux-x64-gnu": "^4.28.1",
35
35
  "i18next": "^24.0.5",
36
- "i18next-browser-languagedetector": "^8.0.0",
36
+ "i18next-browser-languagedetector": "^8.0.2",
37
37
  "i18next-cli-language-detector": "^1.1.8"
38
38
  }
39
39
  }
@@ -38,6 +38,20 @@ export enum I18NEnvironment {
38
38
  Browser
39
39
  }
40
40
 
41
+ /**
42
+ * Convert a string to lower case, skipping words that are all upper case.
43
+ *
44
+ * @param s
45
+ * String.
46
+ *
47
+ * @returns
48
+ * Lower case string.
49
+ */
50
+ function toLowerCase(s: string): string {
51
+ // Words with no lower case letters are preserved as they are likely mnemonics.
52
+ return s.split(" ").map(word => /[a-z]/.test(word) ? word.toLowerCase() : word).join(" ");
53
+ }
54
+
41
55
  /**
42
56
  * Initialize internationalization.
43
57
  *
@@ -84,7 +98,7 @@ export async function i18nInit(environment: I18NEnvironment, debug = false): Pro
84
98
  resources: {}
85
99
  }).then(() => {
86
100
  // Add toLowerCase function.
87
- i18next.services.formatter?.add("toLowerCase", value => typeof value === "string" ? value.toLowerCase() : String(value));
101
+ i18next.services.formatter?.add("toLowerCase", value => typeof value === "string" ? toLowerCase(value) : String(value));
88
102
 
89
103
  // Add pending resource bundles.
90
104
  for (const initResourceBundle of initResourceBundles) {