@uxf/scripts 10.0.0-beta.58 → 10.0.0-beta.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "10.0.0-beta.58",
3
+ "version": "10.0.0-beta.75",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,15 +1,11 @@
1
1
  function findTFunctionNamespaces(pageContent) {
2
- const regex = /\bt\("([a-z0-9\-]+):([a-z0-9\-\.]+)"/g;
2
+ const regex = /\bt\("([a-zA-Z0-9\-]+):([a-zA-Z0-9\-\.]+)"/g;
3
3
  const matches = pageContent.matchAll(regex);
4
4
  const namespaces = new Set();
5
5
 
6
6
  for (const match of matches) {
7
- const translationKey = match[0];
8
- const separatorIndex = translationKey.indexOf(":");
9
- if (separatorIndex !== -1) {
10
- const namespace = translationKey.substring(3, separatorIndex);
11
- namespaces.add(namespace);
12
- }
7
+ const namespace = match[1];
8
+ namespaces.add(namespace);
13
9
  }
14
10
 
15
11
  return Array.from(namespaces);
@@ -4,6 +4,8 @@ const content = `
4
4
  <div>
5
5
  <div>
6
6
  {t("basic:title")}
7
+ {t("basic-dash:title-dash")}
8
+ {t("basicCamel:titleCamel")}
7
9
  </div>
8
10
  <div title={
9
11
  condition
@@ -20,6 +22,8 @@ describe("find namespaces in t functions", function () {
20
22
  it("should find namespaces", function () {
21
23
  expect(findTFunctionNamespaces(content)).toStrictEqual([
22
24
  "basic",
25
+ "basic-dash",
26
+ "basicCamel",
23
27
  "multiline-with-parameters",
24
28
  "with-parameters",
25
29
  "in-translation-parameter",
@@ -1,15 +1,11 @@
1
1
  function findTransComponentNamespaces(pageContent) {
2
- const regex = /<Trans[^>]*?i18nKey=(['"])(.*?)\1[^>]*\/>/g;
2
+ const regex = /<Trans[^>]*?i18nKey="([a-zA-Z0-9\-]+):([a-zA-Z0-9\-\.]+)"/g;
3
3
  const matches = pageContent.matchAll(regex);
4
4
  const namespaces = new Set();
5
5
 
6
6
  for (const match of matches) {
7
- const [, , translationKey] = match;
8
- const separatorIndex = translationKey.indexOf(":");
9
- if (separatorIndex !== -1) {
10
- const namespace = translationKey.substring(0, separatorIndex);
11
- namespaces.add(namespace);
12
- }
7
+ const namespace = match[1];
8
+ namespaces.add(namespace);
13
9
  }
14
10
 
15
11
  return Array.from(namespaces);
@@ -3,11 +3,13 @@ const { findTransComponentNamespaces } = require("./find-trans-component-namespa
3
3
  const content = `
4
4
  <div>
5
5
  <Trans i18nKey="basic:title" />
6
+ <Trans i18nKey="basic-dash:title-dash" />
7
+ <Trans i18nKey="basicCamel:titleCamel" />
6
8
  </div>
7
9
  `;
8
10
 
9
11
  describe("find namespaces in trans component", function () {
10
12
  it("should find namespaces", function () {
11
- expect(findTransComponentNamespaces(content)).toStrictEqual(["basic"]);
13
+ expect(findTransComponentNamespaces(content)).toStrictEqual(["basic", "basic-dash", "basicCamel"]);
12
14
  });
13
15
  });