locize-cli 12.0.5 → 12.0.7

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 CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  Project versioning adheres to [Semantic Versioning](http://semver.org/).
6
6
  Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
7
7
 
8
+ ## [12.0.7](https://github.com/locize/locize-cli/compare/v12.0.6...v12.0.7) - 2026-03-02
9
+
10
+ - improve migrate command
11
+
12
+ ## [12.0.6](https://github.com/locize/locize-cli/compare/v12.0.5...v12.0.6) - 2026-03-02
13
+
14
+ - improve error message when detecting wrong cdnType usage
15
+
8
16
  ## [12.0.5](https://github.com/locize/locize-cli/compare/v12.0.4...v12.0.5) - 2026-02-23
9
17
 
10
18
  - improve download of namespaces with strange content-type
package/README.md CHANGED
@@ -184,7 +184,7 @@ locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-pro
184
184
 
185
185
  ### Step 4: verify
186
186
 
187
- Navigate to your locize project and check the results => [www.locize.app](https://www.locize.app)
187
+ Navigate to your Locize project and check the results => [www.locize.app](https://www.locize.app)
188
188
 
189
189
 
190
190
  ## Push missing keys to locize from your repository (or any other local directory)
@@ -234,7 +234,7 @@ locize save-missing --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-i
234
234
 
235
235
  ### Step 4: verify
236
236
 
237
- Navigate to your locize project and check the results => [www.locize.app](https://www.locize.app)
237
+ Navigate to your Locize project and check the results => [www.locize.app](https://www.locize.app)
238
238
 
239
239
 
240
240
  ## Copy version
@@ -336,7 +336,7 @@ _Passing the argument --replace will empty the optionally existing namespace bef
336
336
 
337
337
  ### Step 4: verify
338
338
 
339
- Navigate to your locize project and check the results => [www.locize.app](https://www.locize.app)
339
+ Navigate to your Locize project and check the results => [www.locize.app](https://www.locize.app)
340
340
 
341
341
 
342
342
 
package/dist/cjs/cli.js CHANGED
@@ -50,7 +50,7 @@ const program = new commander.Command();
50
50
 
51
51
  program
52
52
  .description('The official locize CLI.')
53
- .version('12.0.5'); // This string is replaced with the actual version at build time by rollup
53
+ .version('12.0.7'); // This string is replaced with the actual version at build time by rollup
54
54
  // .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
55
55
  // .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
56
56
 
@@ -68,7 +68,7 @@ program
68
68
  .option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
69
69
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
70
70
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
71
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
71
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
72
72
  .action((options) => {
73
73
  try {
74
74
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -131,7 +131,7 @@ program
131
131
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
132
132
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
133
133
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
134
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
134
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
135
135
  .action((namespace, key, value, options) => {
136
136
  try {
137
137
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -196,7 +196,7 @@ program
196
196
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
197
197
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
198
198
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
199
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
199
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
200
200
  .action((namespace, key, options) => {
201
201
  try {
202
202
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -271,7 +271,7 @@ program
271
271
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
272
272
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
273
273
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
274
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
274
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
275
275
  .action((options) => {
276
276
  try {
277
277
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -354,7 +354,7 @@ program
354
354
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
355
355
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
356
356
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
357
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
357
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
358
358
  .action((namespace, key, options) => {
359
359
  try {
360
360
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -431,7 +431,7 @@ program
431
431
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
432
432
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
433
433
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
434
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
434
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
435
435
  .action((options) => {
436
436
  try {
437
437
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -541,7 +541,7 @@ program
541
541
  .option('-n, --namespace <ns>', 'The namespace that should be targeted (you can also pass a comma separated list)')
542
542
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
543
543
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
544
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
544
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
545
545
  .action((options) => {
546
546
  try {
547
547
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -620,7 +620,7 @@ program
620
620
  .option('--iv, --ignore-if-version-exists <true|false>', 'The project-id that should be used (default: false)', 'false')
621
621
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
622
622
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
623
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
623
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
624
624
  .action((fromVersion, options) => {
625
625
  try {
626
626
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -675,7 +675,7 @@ program
675
675
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
676
676
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
677
677
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
678
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
678
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
679
679
  .action((version, options) => {
680
680
  try {
681
681
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -725,7 +725,7 @@ program
725
725
  .option('-t, --tenants <true|false>', 'Publish also tenants (if using multi-tenant setup) (default: false)', 'false')
726
726
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
727
727
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
728
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
728
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
729
729
  .action((options) => {
730
730
  try {
731
731
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -780,7 +780,7 @@ program
780
780
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
781
781
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
782
782
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
783
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
783
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
784
784
  .action((namespace, options) => {
785
785
  try {
786
786
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -869,7 +869,7 @@ program
869
869
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
870
870
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
871
871
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
872
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
872
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
873
873
  .action((branch, options) => {
874
874
  try {
875
875
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -923,7 +923,7 @@ program
923
923
  .option('-d, --delete <true|false>', 'This will delete the branch after merging. (default: false)', 'false')
924
924
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
925
925
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
926
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
926
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
927
927
  .action((branch, options) => {
928
928
  try {
929
929
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -974,7 +974,7 @@ program
974
974
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
975
975
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
976
976
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
977
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
977
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
978
978
  .action((branch, options) => {
979
979
  try {
980
980
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -2,10 +2,16 @@
2
2
 
3
3
  var request = require('./request.js');
4
4
 
5
+ const getOtherApiEndpoint = (apiEndpoint) => {
6
+ if (apiEndpoint.indexOf('.lite.locize.') > 0) {
7
+ return apiEndpoint.replace('.lite.locize.', '.locize.')
8
+ } else if (apiEndpoint.indexOf('.locize.') > 0) {
9
+ return apiEndpoint.replace('.locize.', '.lite.locize.')
10
+ }
11
+ };
12
+
5
13
  const getRemoteLanguages = async (opt) => {
6
- const { res, obj } = await request(opt.apiEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '&cache=no' : ''), {
7
- method: 'get'
8
- });
14
+ const { res, obj } = await request(opt.apiEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '&cache=no' : ''), { method: 'get' });
9
15
  if ((obj && (obj.errorMessage || obj.message))) {
10
16
  if (res && res.statusText && res.status) {
11
17
  throw new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message))
@@ -15,7 +21,13 @@ const getRemoteLanguages = async (opt) => {
15
21
  if (res.status >= 300) throw new Error(res.statusText + ' (' + res.status + ')')
16
22
 
17
23
  if (Object.keys(obj).length === 0) {
18
- throw new Error('Project with id "' + opt.projectId + '" not found!')
24
+ let errMsg = 'Project with id "' + opt.projectId + '" not found!';
25
+ const otherEndpoint = getOtherApiEndpoint(opt.apiEndpoint);
26
+ const { res: res2, obj: obj2 } = await request(otherEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '' : '&cache=no'), { method: 'get' });
27
+ if (res2.status === 200 && Object.keys(obj2).length > 0) {
28
+ errMsg += ` It seems you're using the wrong cdnType. Your Locize project is configured to use "${opt.cdnType === 'standard' ? 'pro' : 'standard'}" but here you've configured "${opt.cdnType}".`;
29
+ }
30
+ throw new Error(errMsg)
19
31
  }
20
32
 
21
33
  const lngs = Object.keys(obj);
@@ -26,6 +26,10 @@ const load = async (namespaces) => {
26
26
  try {
27
27
  const data = await fs.promises.readFile(ns.path, 'utf8');
28
28
  ns.value = flatten(JSON.parse(data));
29
+ // remove all empty strings for migrate (i.e. used via i18next-cli)
30
+ Object.keys(ns.value).forEach((k) => {
31
+ if (ns.value[k] === '') delete ns.value[k];
32
+ });
29
33
  } catch (err) {
30
34
  console.error(colors.red(err.stack));
31
35
  ns.value = {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "12.0.5",
3
+ "version": "12.0.7",
4
4
  "type": "commonjs"
5
5
  }
@@ -39,7 +39,7 @@ async function request (url, options) {
39
39
  }
40
40
 
41
41
  options.headers = options.headers || {};
42
- options.headers['User-Agent'] = `locize-cli/v12.0.5 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
42
+ options.headers['User-Agent'] = `locize-cli/v12.0.7 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
43
43
  options.headers['X-User-Agent'] = options.headers['User-Agent'];
44
44
  if (options.body || options.method !== 'get') options.headers['Content-Type'] = 'application/json';
45
45
  if (options.body) {
package/dist/esm/cli.js CHANGED
@@ -48,7 +48,7 @@ const program = new Command();
48
48
 
49
49
  program
50
50
  .description('The official locize CLI.')
51
- .version('12.0.5'); // This string is replaced with the actual version at build time by rollup
51
+ .version('12.0.7'); // This string is replaced with the actual version at build time by rollup
52
52
  // .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
53
53
  // .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`);
54
54
 
@@ -66,7 +66,7 @@ program
66
66
  .option('-r, --replace <true|false>', 'This will empty the optionally existing namespace before saving the new translations. (default: false)', 'false')
67
67
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
68
68
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
69
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
69
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
70
70
  .action((options) => {
71
71
  try {
72
72
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -129,7 +129,7 @@ program
129
129
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
130
130
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
131
131
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
132
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
132
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
133
133
  .action((namespace, key, value, options) => {
134
134
  try {
135
135
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -194,7 +194,7 @@ program
194
194
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
195
195
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
196
196
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
197
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
197
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
198
198
  .action((namespace, key, options) => {
199
199
  try {
200
200
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -269,7 +269,7 @@ program
269
269
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
270
270
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
271
271
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
272
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
272
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
273
273
  .action((options) => {
274
274
  try {
275
275
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -352,7 +352,7 @@ program
352
352
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
353
353
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
354
354
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
355
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
355
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
356
356
  .action((namespace, key, options) => {
357
357
  try {
358
358
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -429,7 +429,7 @@ program
429
429
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
430
430
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
431
431
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
432
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
432
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
433
433
  .action((options) => {
434
434
  try {
435
435
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -539,7 +539,7 @@ program
539
539
  .option('-n, --namespace <ns>', 'The namespace that should be targeted (you can also pass a comma separated list)')
540
540
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
541
541
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
542
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
542
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
543
543
  .action((options) => {
544
544
  try {
545
545
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -618,7 +618,7 @@ program
618
618
  .option('--iv, --ignore-if-version-exists <true|false>', 'The project-id that should be used (default: false)', 'false')
619
619
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
620
620
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
621
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
621
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
622
622
  .action((fromVersion, options) => {
623
623
  try {
624
624
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -673,7 +673,7 @@ program
673
673
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
674
674
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
675
675
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
676
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
676
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
677
677
  .action((version, options) => {
678
678
  try {
679
679
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -723,7 +723,7 @@ program
723
723
  .option('-t, --tenants <true|false>', 'Publish also tenants (if using multi-tenant setup) (default: false)', 'false')
724
724
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
725
725
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
726
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
726
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
727
727
  .action((options) => {
728
728
  try {
729
729
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -778,7 +778,7 @@ program
778
778
  .option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
779
779
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
780
780
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
781
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
781
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
782
782
  .action((namespace, options) => {
783
783
  try {
784
784
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -867,7 +867,7 @@ program
867
867
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
868
868
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
869
869
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
870
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
870
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
871
871
  .action((branch, options) => {
872
872
  try {
873
873
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -921,7 +921,7 @@ program
921
921
  .option('-d, --delete <true|false>', 'This will delete the branch after merging. (default: false)', 'false')
922
922
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
923
923
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
924
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
924
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
925
925
  .action((branch, options) => {
926
926
  try {
927
927
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -972,7 +972,7 @@ program
972
972
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
973
973
  .option('-a, --api-endpoint <url>', `Specify the api-endpoint url that should be used (default: ${defaultApiEndpoint})`)
974
974
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
975
- .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your locize project) (default: ${defaultCdnType})`)
975
+ .option('--ct, --cdn-type <standard|pro>', `Specify the cdn endpoint that should be used (depends on which cdn type you've in your Locize project) (default: ${defaultCdnType})`)
976
976
  .action((branch, options) => {
977
977
  try {
978
978
  config = ini.parse(fs.readFileSync(options.configPath, 'utf-8')) || config;
@@ -1,9 +1,15 @@
1
1
  import request from './request.js';
2
2
 
3
+ const getOtherApiEndpoint = (apiEndpoint) => {
4
+ if (apiEndpoint.indexOf('.lite.locize.') > 0) {
5
+ return apiEndpoint.replace('.lite.locize.', '.locize.')
6
+ } else if (apiEndpoint.indexOf('.locize.') > 0) {
7
+ return apiEndpoint.replace('.locize.', '.lite.locize.')
8
+ }
9
+ };
10
+
3
11
  const getRemoteLanguages = async (opt) => {
4
- const { res, obj } = await request(opt.apiEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '&cache=no' : ''), {
5
- method: 'get'
6
- });
12
+ const { res, obj } = await request(opt.apiEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '&cache=no' : ''), { method: 'get' });
7
13
  if ((obj && (obj.errorMessage || obj.message))) {
8
14
  if (res && res.statusText && res.status) {
9
15
  throw new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message))
@@ -13,7 +19,13 @@ const getRemoteLanguages = async (opt) => {
13
19
  if (res.status >= 300) throw new Error(res.statusText + ' (' + res.status + ')')
14
20
 
15
21
  if (Object.keys(obj).length === 0) {
16
- throw new Error('Project with id "' + opt.projectId + '" not found!')
22
+ let errMsg = 'Project with id "' + opt.projectId + '" not found!';
23
+ const otherEndpoint = getOtherApiEndpoint(opt.apiEndpoint);
24
+ const { res: res2, obj: obj2 } = await request(otherEndpoint + '/languages/' + opt.projectId + '?ts=' + Date.now() + (opt.cdnType === 'standard' ? '' : '&cache=no'), { method: 'get' });
25
+ if (res2.status === 200 && Object.keys(obj2).length > 0) {
26
+ errMsg += ` It seems you're using the wrong cdnType. Your Locize project is configured to use "${opt.cdnType === 'standard' ? 'pro' : 'standard'}" but here you've configured "${opt.cdnType}".`;
27
+ }
28
+ throw new Error(errMsg)
17
29
  }
18
30
 
19
31
  const lngs = Object.keys(obj);
@@ -24,6 +24,10 @@ const load = async (namespaces) => {
24
24
  try {
25
25
  const data = await fs.promises.readFile(ns.path, 'utf8');
26
26
  ns.value = flatten(JSON.parse(data));
27
+ // remove all empty strings for migrate (i.e. used via i18next-cli)
28
+ Object.keys(ns.value).forEach((k) => {
29
+ if (ns.value[k] === '') delete ns.value[k];
30
+ });
27
31
  } catch (err) {
28
32
  console.error(colors.red(err.stack));
29
33
  ns.value = {};
@@ -37,7 +37,7 @@ async function request (url, options) {
37
37
  }
38
38
 
39
39
  options.headers = options.headers || {};
40
- options.headers['User-Agent'] = `locize-cli/v12.0.5 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
40
+ options.headers['User-Agent'] = `locize-cli/v12.0.7 (node/${process.version}; ${process.platform} ${process.arch})`; // This string is replaced with the actual version at build time by rollup
41
41
  options.headers['X-User-Agent'] = options.headers['User-Agent'];
42
42
  if (options.body || options.method !== 'get') options.headers['Content-Type'] = 'application/json';
43
43
  if (options.body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "12.0.5",
3
+ "version": "12.0.7",
4
4
  "description": "locize cli to import locales",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -29,9 +29,9 @@
29
29
  "android-string-resource": "2.3.10",
30
30
  "cacheable-lookup": "6.1.0",
31
31
  "colors": "1.4.0",
32
- "commander": "14.0.2",
32
+ "commander": "14.0.3",
33
33
  "diff": "8.0.3",
34
- "dotenv": "17.2.3",
34
+ "dotenv": "17.3.1",
35
35
  "fast-csv": "5.0.5",
36
36
  "flat": "5.0.2",
37
37
  "fluent_conv": "3.3.0",
@@ -43,7 +43,7 @@
43
43
  "lodash.clonedeep": "4.5.0",
44
44
  "mkdirp": "3.0.1",
45
45
  "resx": "2.0.4",
46
- "rimraf": "6.1.2",
46
+ "rimraf": "6.1.3",
47
47
  "strings-file": "0.0.5",
48
48
  "tmexchange": "2.0.6",
49
49
  "xliff": "6.3.0",
@@ -53,12 +53,12 @@
53
53
  "devDependencies": {
54
54
  "@rollup/plugin-replace": "6.0.3",
55
55
  "@rollup/plugin-terser": "0.4.4",
56
- "@yao-pkg/pkg": "6.12.0",
56
+ "@yao-pkg/pkg": "6.14.1",
57
57
  "eslint": "9.39.2",
58
58
  "eslint-plugin-import": "2.32.0",
59
59
  "gh-release": "7.0.2",
60
- "neostandard": "0.12.2",
61
- "rollup": "4.56.0",
60
+ "neostandard": "0.13.0",
61
+ "rollup": "4.59.0",
62
62
  "vitest": "4.0.18"
63
63
  },
64
64
  "scripts": {