i18n-tools-mcp 1.0.4 → 1.0.5

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
@@ -33,7 +33,7 @@ Arguments:
33
33
 
34
34
  ## Directory structures
35
35
 
36
- Both flat and namespaced layouts are auto-detected.
36
+ Both flat and namespaced layouts are auto-detected. JSON files directly in the directory make it flat; other folders next to them (such as Laravel's `resources/lang/vendor`) are then ignored.
37
37
 
38
38
  **Flat** — one JSON file per locale:
39
39
 
@@ -8,32 +8,37 @@ function sanitize(value) {
8
8
  .replace(/[\u201C\u201D\u201E\u201F\u2033\u2036]/g, '"')
9
9
  .replace(/[\u2018\u2019\u201A\u201B\u2032\u2035]/g, "'");
10
10
  }
11
+ /**
12
+ * JSON files directly in the directory are the locales (`en.json`); only without them do
13
+ * subdirectories hold namespaced locales (`en/common.json`). Flat files win so that an
14
+ * unrelated folder next to them, such as Laravel's `resources/lang/vendor`, is ignored.
15
+ */
11
16
  function discoverLocaleFiles(dir) {
12
17
  const resolvedDir = resolve(dir);
13
18
  const entries = readdirSync(resolvedDir, { withFileTypes: true });
14
- const subdirs = entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
15
- if (subdirs.length > 0) {
16
- const files = [];
17
- for (const subdir of subdirs) {
18
- const localePath = join(resolvedDir, subdir.name);
19
- const jsonFiles = readdirSync(localePath).filter((f) => f.endsWith('.json')).sort();
20
- for (const f of jsonFiles) {
21
- files.push({
22
- locale: subdir.name,
23
- namespace: basename(f, '.json'),
24
- path: join(localePath, f),
25
- });
26
- }
27
- }
28
- return files;
29
- }
30
19
  const jsonFiles = entries
31
20
  .filter((e) => e.isFile() && e.name.endsWith('.json'))
32
21
  .sort((a, b) => a.name.localeCompare(b.name));
33
- return jsonFiles.map((f) => ({
34
- locale: basename(f.name, '.json'),
35
- path: join(resolvedDir, f.name),
36
- }));
22
+ if (jsonFiles.length > 0) {
23
+ return jsonFiles.map((f) => ({
24
+ locale: basename(f.name, '.json'),
25
+ path: join(resolvedDir, f.name),
26
+ }));
27
+ }
28
+ const subdirs = entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
29
+ const files = [];
30
+ for (const subdir of subdirs) {
31
+ const localePath = join(resolvedDir, subdir.name);
32
+ const namespaceFiles = readdirSync(localePath).filter((f) => f.endsWith('.json')).sort();
33
+ for (const f of namespaceFiles) {
34
+ files.push({
35
+ locale: subdir.name,
36
+ namespace: basename(f, '.json'),
37
+ path: join(localePath, f),
38
+ });
39
+ }
40
+ }
41
+ return files;
37
42
  }
38
43
  function parseKey(key) {
39
44
  const colonIndex = key.indexOf(NS_SEPARATOR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18n-tools-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "MCP server for managing JSON translation files",
5
5
  "type": "module",
6
6
  "bin": {