ai-localize-locale-engine 1.0.0 → 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # ai-localize-locale-engine
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - versoion change
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - ai-localize-shared@2.0.0
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { LocaleFile, DetectedText } from '@ai-localize/shared';
1
+ import { LocaleFile, DetectedText } from 'ai-localize-shared';
2
2
 
3
3
  interface ExtractOptions {
4
4
  defaultLanguage?: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LocaleFile, DetectedText } from '@ai-localize/shared';
1
+ import { LocaleFile, DetectedText } from 'ai-localize-shared';
2
2
 
3
3
  interface ExtractOptions {
4
4
  defaultLanguage?: string;
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ __export(index_exports, {
40
40
  module.exports = __toCommonJS(index_exports);
41
41
 
42
42
  // src/extractor.ts
43
- var import_shared = require("@ai-localize/shared");
43
+ var import_ai_localize_shared = require("ai-localize-shared");
44
44
  var LocaleExtractor = class {
45
45
  options;
46
46
  constructor(options = {}) {
@@ -56,14 +56,14 @@ var LocaleExtractor = class {
56
56
  for (const dt of detectedTexts) {
57
57
  let key = dt.suggestedKey;
58
58
  if (keyValueMap.has(key) && keyValueMap.get(key) !== dt.text) {
59
- key = (0, import_shared.resolveKeyCollision)(key, existingKeys);
59
+ key = (0, import_ai_localize_shared.resolveKeyCollision)(key, existingKeys);
60
60
  }
61
61
  existingKeys.add(key);
62
62
  keyValueMap.set(key, dt.text);
63
63
  }
64
64
  const namespaceMap = /* @__PURE__ */ new Map();
65
65
  for (const [key, value] of keyValueMap) {
66
- const { namespace, localKey } = this.options.namespaceSplitting ? (0, import_shared.splitKeyNamespace)(key) : { namespace: import_shared.DEFAULT_NAMESPACE, localKey: key };
66
+ const { namespace, localKey } = this.options.namespaceSplitting ? (0, import_ai_localize_shared.splitKeyNamespace)(key) : { namespace: import_ai_localize_shared.DEFAULT_NAMESPACE, localKey: key };
67
67
  if (!namespaceMap.has(namespace)) namespaceMap.set(namespace, {});
68
68
  namespaceMap.get(namespace)[localKey] = value;
69
69
  }
@@ -87,7 +87,7 @@ var LocaleExtractor = class {
87
87
 
88
88
  // src/writer.ts
89
89
  var path = __toESM(require("path"));
90
- var import_shared2 = require("@ai-localize/shared");
90
+ var import_ai_localize_shared2 = require("ai-localize-shared");
91
91
  var LocaleWriter = class {
92
92
  options;
93
93
  constructor(options) {
@@ -100,14 +100,14 @@ var LocaleWriter = class {
100
100
  for (const lf of localeFiles) {
101
101
  const filePath = this.resolveFilePath(lf);
102
102
  lf.filePath = filePath;
103
- (0, import_shared2.ensureDir)(path.dirname(filePath));
104
- const existing = (0, import_shared2.readJsonSafe)(filePath);
103
+ (0, import_ai_localize_shared2.ensureDir)(path.dirname(filePath));
104
+ const existing = (0, import_ai_localize_shared2.readJsonSafe)(filePath);
105
105
  if (existing && this.options.merge) {
106
106
  const mergedEntries = this.mergeEntries(existing, lf.entries);
107
- (0, import_shared2.writeJson)(filePath, this.options.sort ? this.sort(mergedEntries) : mergedEntries);
107
+ (0, import_ai_localize_shared2.writeJson)(filePath, this.options.sort ? this.sort(mergedEntries) : mergedEntries);
108
108
  merged.push(filePath);
109
109
  } else {
110
- (0, import_shared2.writeJson)(filePath, this.options.sort ? this.sort(lf.entries) : lf.entries);
110
+ (0, import_ai_localize_shared2.writeJson)(filePath, this.options.sort ? this.sort(lf.entries) : lf.entries);
111
111
  created.push(filePath);
112
112
  }
113
113
  written.push(filePath);
@@ -149,7 +149,7 @@ function findUnusedKeys(localeKeys, sourceKeys) {
149
149
  // src/synchronizer.ts
150
150
  var fs = __toESM(require("fs"));
151
151
  var path2 = __toESM(require("path"));
152
- var import_shared3 = require("@ai-localize/shared");
152
+ var import_ai_localize_shared3 = require("ai-localize-shared");
153
153
  var LocaleSynchronizer = class {
154
154
  constructor(localesDir, defaultLanguage = "en") {
155
155
  this.localesDir = localesDir;
@@ -165,12 +165,12 @@ var LocaleSynchronizer = class {
165
165
  const defaultFiles = fs.readdirSync(defaultDir).filter((f) => f.endsWith(".json"));
166
166
  const langDirs = fs.readdirSync(this.localesDir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== this.defaultLanguage).map((e) => e.name);
167
167
  for (const namespace of defaultFiles) {
168
- const defaultEntries = (0, import_shared3.readJsonSafe)(path2.join(defaultDir, namespace));
168
+ const defaultEntries = (0, import_ai_localize_shared3.readJsonSafe)(path2.join(defaultDir, namespace));
169
169
  if (!defaultEntries) continue;
170
170
  for (const lang of langDirs) {
171
171
  const targetPath = path2.join(this.localesDir, lang, namespace);
172
- (0, import_shared3.ensureDir)(path2.dirname(targetPath));
173
- const existing = (0, import_shared3.readJsonSafe)(targetPath) || {};
172
+ (0, import_ai_localize_shared3.ensureDir)(path2.dirname(targetPath));
173
+ const existing = (0, import_ai_localize_shared3.readJsonSafe)(targetPath) || {};
174
174
  let changed = false;
175
175
  for (const key of Object.keys(defaultEntries)) {
176
176
  if (!(key in existing)) {
@@ -180,7 +180,7 @@ var LocaleSynchronizer = class {
180
180
  }
181
181
  }
182
182
  if (changed) {
183
- (0, import_shared3.writeJson)(targetPath, existing);
183
+ (0, import_ai_localize_shared3.writeJson)(targetPath, existing);
184
184
  updated.push(targetPath);
185
185
  }
186
186
  }
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  splitKeyNamespace,
4
4
  resolveKeyCollision,
5
5
  DEFAULT_NAMESPACE
6
- } from "@ai-localize/shared";
6
+ } from "ai-localize-shared";
7
7
  var LocaleExtractor = class {
8
8
  options;
9
9
  constructor(options = {}) {
@@ -50,7 +50,7 @@ var LocaleExtractor = class {
50
50
 
51
51
  // src/writer.ts
52
52
  import * as path from "path";
53
- import { writeJson, readJsonSafe, ensureDir } from "@ai-localize/shared";
53
+ import { writeJson, readJsonSafe, ensureDir } from "ai-localize-shared";
54
54
  var LocaleWriter = class {
55
55
  options;
56
56
  constructor(options) {
@@ -112,7 +112,7 @@ function findUnusedKeys(localeKeys, sourceKeys) {
112
112
  // src/synchronizer.ts
113
113
  import * as fs from "fs";
114
114
  import * as path2 from "path";
115
- import { readJsonSafe as readJsonSafe2, writeJson as writeJson2, ensureDir as ensureDir2 } from "@ai-localize/shared";
115
+ import { readJsonSafe as readJsonSafe2, writeJson as writeJson2, ensureDir as ensureDir2 } from "ai-localize-shared";
116
116
  var LocaleSynchronizer = class {
117
117
  constructor(localesDir, defaultLanguage = "en") {
118
118
  this.localesDir = localesDir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-localize-locale-engine",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Locale file generation, merging, deduplication and synchronization",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,7 +13,7 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "ai-localize-shared": "1.0.0"
16
+ "ai-localize-shared": "2.0.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "tsup": "^8.0.1",
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { LocaleExtractor } from '../extractor.js';
3
- import type { DetectedText } from '@ai-localize/shared';
3
+ import type { DetectedText } from 'ai-localize-shared';
4
4
 
5
5
  const mockTexts: DetectedText[] = [
6
6
  {
@@ -1,4 +1,4 @@
1
- import type { DetectedText } from "@ai-localize/shared";
1
+ import type { DetectedText } from "ai-localize-shared";
2
2
 
3
3
  export function deduplicateTexts(texts: DetectedText[]): DetectedText[] {
4
4
  const seen = new Map<string, DetectedText>();
package/src/extractor.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { DetectedText, LocaleFile } from "@ai-localize/shared";
1
+ import type { DetectedText, LocaleFile } from "ai-localize-shared";
2
2
  import {
3
3
  splitKeyNamespace,
4
4
  resolveKeyCollision,
5
5
  DEFAULT_NAMESPACE,
6
- } from "@ai-localize/shared";
6
+ } from "ai-localize-shared";
7
7
 
8
8
  export interface ExtractOptions {
9
9
  defaultLanguage?: string;
@@ -1,6 +1,6 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
- import { readJsonSafe, writeJson, ensureDir } from "@ai-localize/shared";
3
+ import { readJsonSafe, writeJson, ensureDir } from "ai-localize-shared";
4
4
 
5
5
  export class LocaleSynchronizer {
6
6
  constructor(private localesDir: string, private defaultLanguage = "en") {}
package/src/writer.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as path from "path";
2
- import type { LocaleFile } from "@ai-localize/shared";
3
- import { writeJson, readJsonSafe, ensureDir } from "@ai-localize/shared";
2
+ import type { LocaleFile } from "ai-localize-shared";
3
+ import { writeJson, readJsonSafe, ensureDir } from "ai-localize-shared";
4
4
 
5
5
  export interface WriteOptions {
6
6
  localesDir: string;