@leancodepl/intl 9.7.2 → 9.7.4

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +201 -0
  3. package/README.md +68 -7
  4. package/{src → dist}/TranslationsServiceClient.d.ts +9 -1
  5. package/dist/TranslationsServiceClient.d.ts.map +1 -0
  6. package/dist/bin.cjs +2 -0
  7. package/dist/bin.d.ts +3 -0
  8. package/dist/bin.d.ts.map +1 -0
  9. package/dist/bin.js +103 -0
  10. package/{src → dist}/commands/diff.d.ts +3 -2
  11. package/dist/commands/diff.d.ts.map +1 -0
  12. package/{src → dist}/commands/download.d.ts +3 -2
  13. package/dist/commands/download.d.ts.map +1 -0
  14. package/{src → dist}/commands/local.d.ts +3 -2
  15. package/dist/commands/local.d.ts.map +1 -0
  16. package/{src → dist}/commands/sync.d.ts +3 -2
  17. package/dist/commands/sync.d.ts.map +1 -0
  18. package/{src → dist}/commands/upload.d.ts +3 -2
  19. package/dist/commands/upload.d.ts.map +1 -0
  20. package/{src → dist}/formatjs.d.ts +1 -0
  21. package/dist/formatjs.d.ts.map +1 -0
  22. package/dist/index.cjs +1 -0
  23. package/dist/index.d.ts +7 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +9 -0
  26. package/dist/loadConfig.d.ts +12 -0
  27. package/dist/loadConfig.d.ts.map +1 -0
  28. package/dist/logger.d.ts +9 -0
  29. package/dist/logger.d.ts.map +1 -0
  30. package/{src → dist}/mergeWithEnv.d.ts +1 -0
  31. package/dist/mergeWithEnv.d.ts.map +1 -0
  32. package/dist/mkTranslationsServiceClient-CYeFDsNC.cjs +5 -0
  33. package/dist/mkTranslationsServiceClient-D62VGNcU.js +1578 -0
  34. package/{src → dist}/mkTranslationsServiceClient.d.ts +2 -1
  35. package/dist/mkTranslationsServiceClient.d.ts.map +1 -0
  36. package/{src → dist}/poeditor/POEditorClient.d.ts +8 -2
  37. package/dist/poeditor/POEditorClient.d.ts.map +1 -0
  38. package/{src → dist}/poeditor/api.generated/api.d.ts +30 -41
  39. package/dist/poeditor/api.generated/api.d.ts.map +1 -0
  40. package/{src → dist}/poeditor/api.generated/base.d.ts +3 -13
  41. package/dist/poeditor/api.generated/base.d.ts.map +1 -0
  42. package/{src → dist}/poeditor/api.generated/common.d.ts +4 -14
  43. package/dist/poeditor/api.generated/common.d.ts.map +1 -0
  44. package/{src → dist}/poeditor/api.generated/configuration.d.ts +1 -0
  45. package/dist/poeditor/api.generated/configuration.d.ts.map +1 -0
  46. package/{src → dist}/poeditor/api.generated/index.d.ts +3 -2
  47. package/dist/poeditor/api.generated/index.d.ts.map +1 -0
  48. package/{src → dist}/poeditor/generatePoeditorClient.d.ts +1 -0
  49. package/dist/poeditor/generatePoeditorClient.d.ts.map +1 -0
  50. package/package.json +25 -7
  51. package/src/TranslationsServiceClient.js +0 -3
  52. package/src/TranslationsServiceClient.js.map +0 -1
  53. package/src/bin.d.ts +0 -2
  54. package/src/bin.js +0 -129
  55. package/src/bin.js.map +0 -1
  56. package/src/commands/diff.js +0 -35
  57. package/src/commands/diff.js.map +0 -1
  58. package/src/commands/download.js +0 -39
  59. package/src/commands/download.js.map +0 -1
  60. package/src/commands/local.js +0 -117
  61. package/src/commands/local.js.map +0 -1
  62. package/src/commands/sync.js +0 -34
  63. package/src/commands/sync.js.map +0 -1
  64. package/src/commands/upload.js +0 -32
  65. package/src/commands/upload.js.map +0 -1
  66. package/src/formatjs.js +0 -60
  67. package/src/formatjs.js.map +0 -1
  68. package/src/index.d.ts +0 -6
  69. package/src/index.js +0 -16
  70. package/src/index.js.map +0 -1
  71. package/src/mergeWithEnv.js +0 -14
  72. package/src/mergeWithEnv.js.map +0 -1
  73. package/src/mkTranslationsServiceClient.js +0 -14
  74. package/src/mkTranslationsServiceClient.js.map +0 -1
  75. package/src/poeditor/POEditorClient.js +0 -88
  76. package/src/poeditor/POEditorClient.js.map +0 -1
  77. package/src/poeditor/api.generated/api.js +0 -2654
  78. package/src/poeditor/api.generated/api.js.map +0 -1
  79. package/src/poeditor/api.generated/base.js +0 -69
  80. package/src/poeditor/api.generated/base.js.map +0 -1
  81. package/src/poeditor/api.generated/common.js +0 -146
  82. package/src/poeditor/api.generated/common.js.map +0 -1
  83. package/src/poeditor/api.generated/configuration.js +0 -100
  84. package/src/poeditor/api.generated/configuration.js.map +0 -1
  85. package/src/poeditor/api.generated/index.js +0 -18
  86. package/src/poeditor/api.generated/index.js.map +0 -1
  87. package/src/poeditor/generatePoeditorClient.js +0 -54
  88. package/src/poeditor/generatePoeditorClient.js.map +0 -1
package/src/bin.js DELETED
@@ -1,129 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const commander_1 = require("commander");
5
- const v4_1 = require("zod/v4");
6
- const diff_1 = require("./commands/diff");
7
- const download_1 = require("./commands/download");
8
- const local_1 = require("./commands/local");
9
- const sync_1 = require("./commands/sync");
10
- const upload_1 = require("./commands/upload");
11
- const mergeWithEnv_1 = require("./mergeWithEnv");
12
- const mkTranslationsServiceClient_1 = require("./mkTranslationsServiceClient");
13
- const translationsServiceOptionsSchema = v4_1.z.object({
14
- poeditorApiToken: v4_1.z.string().optional(),
15
- poeditorProjectId: v4_1.z.number().optional(),
16
- });
17
- commander_1.program.name("intl").description("CLI tool for managing formatjs translations with translation services");
18
- commander_1.program
19
- .command("local")
20
- .description("Extract, download from translation service, and compile formatjs translations locally")
21
- .option("-s, --src-pattern <pattern>", "Source file pattern for extraction", "src/**/!(*.d).{ts,tsx}")
22
- .option("-o, --output-dir <dir>", "Output directory for compiled translations", "lang")
23
- .option("-d, --default-language <lang>", "Default language for translations")
24
- .option("-t, --poeditor-api-token <token>", "POEditor API token (can also use POEDITOR_API_TOKEN env var)")
25
- .option("-p, --poeditor-project-id <id>", "POEditor project ID", value => parseInt(value, 10))
26
- .action(async (options) => {
27
- const parsedOptions = local_1.localCommandOptionsSchema.extend(translationsServiceOptionsSchema.shape).parse(options);
28
- const config = (0, mergeWithEnv_1.mergeWithEnv)(parsedOptions);
29
- const translationsServiceClient = config.poeditorApiToken && config.poeditorProjectId
30
- ? (0, mkTranslationsServiceClient_1.mkTranslationsServiceClient)({
31
- poeditorApiToken: config.poeditorApiToken,
32
- poeditorProjectId: config.poeditorProjectId,
33
- })
34
- : undefined;
35
- await (0, local_1.local)({
36
- srcPattern: config.srcPattern,
37
- outputDir: config.outputDir,
38
- defaultLanguage: config.defaultLanguage,
39
- translationsServiceClient,
40
- });
41
- });
42
- commander_1.program
43
- .command("upload")
44
- .description("Extract terms and upload to translation service")
45
- .option("-s, --src-pattern <pattern>", "Source file pattern for extraction", "src/**/!(*.d).{ts,tsx}")
46
- .option("-t, --poeditor-api-token <token>", "POEditor API token (can also use POEDITOR_API_TOKEN env var)")
47
- .option("-p, --poeditor-project-id <id>", "POEditor project ID", value => parseInt(value, 10))
48
- .option("-d, --default-language <lang>", "Default language for translations")
49
- .action(async (options) => {
50
- const parsedOptions = upload_1.uploadCommandOptionsSchema.extend(translationsServiceOptionsSchema.shape).parse(options);
51
- const config = (0, mergeWithEnv_1.mergeWithEnv)(parsedOptions);
52
- if (!config.poeditorApiToken || !config.poeditorProjectId) {
53
- console.error("Translation service API token and project ID are required for upload command");
54
- process.exit(1);
55
- }
56
- const translationsServiceClient = (0, mkTranslationsServiceClient_1.mkTranslationsServiceClient)({
57
- poeditorApiToken: config.poeditorApiToken,
58
- poeditorProjectId: config.poeditorProjectId,
59
- });
60
- await (0, upload_1.upload)({
61
- srcPattern: config.srcPattern,
62
- translationsServiceClient,
63
- defaultLanguage: config.defaultLanguage,
64
- });
65
- });
66
- commander_1.program
67
- .command("download")
68
- .description("Download translations from translation service and compile them")
69
- .option("-o, --output-dir <dir>", "Output directory for compiled translations", "lang")
70
- .option("-l, --languages <langs...>", "Languages to download")
71
- .option("-t, --poeditor-api-token <token>", "POEditor API token (can also use POEDITOR_API_TOKEN env var)")
72
- .option("-p, --poeditor-project-id <id>", "POEditor project ID", value => parseInt(value, 10))
73
- .action(async (options) => {
74
- const parsedOptions = download_1.downloadCommandOptionsSchema.extend(translationsServiceOptionsSchema.shape).parse(options);
75
- const config = (0, mergeWithEnv_1.mergeWithEnv)(parsedOptions);
76
- const translationsServiceClient = (0, mkTranslationsServiceClient_1.mkTranslationsServiceClient)({
77
- poeditorApiToken: config.poeditorApiToken,
78
- poeditorProjectId: config.poeditorProjectId,
79
- });
80
- await (0, download_1.download)({
81
- outputDir: config.outputDir,
82
- languages: config.languages,
83
- translationsServiceClient,
84
- });
85
- });
86
- commander_1.program
87
- .command("sync")
88
- .description("Upload local changes and download updated translations")
89
- .option("-s, --src-pattern <pattern>", "Source file pattern for extraction", "src/**/!(*.d).{ts,tsx}")
90
- .option("-o, --output-dir <dir>", "Output directory for compiled translations", "lang")
91
- .option("-l, --languages <langs...>", "Languages to download")
92
- .option("-t, --poeditor-api-token <token>", "POEditor API token (can also use POEDITOR_API_TOKEN env var)")
93
- .option("-p, --poeditor-project-id <id>", "POEditor project ID", value => parseInt(value, 10))
94
- .option("-d, --default-language <lang>", "Default language for translations")
95
- .action(async (options) => {
96
- const parsedOptions = sync_1.syncCommandOptionsSchema.extend(translationsServiceOptionsSchema.shape).parse(options);
97
- const config = (0, mergeWithEnv_1.mergeWithEnv)(parsedOptions);
98
- const translationsServiceClient = (0, mkTranslationsServiceClient_1.mkTranslationsServiceClient)({
99
- poeditorApiToken: config.poeditorApiToken,
100
- poeditorProjectId: config.poeditorProjectId,
101
- });
102
- await (0, sync_1.sync)({
103
- srcPattern: config.srcPattern,
104
- outputDir: config.outputDir,
105
- languages: config.languages,
106
- translationsServiceClient,
107
- defaultLanguage: config.defaultLanguage,
108
- });
109
- });
110
- commander_1.program
111
- .command("diff")
112
- .description("Compare local terms with translation service to find unused terms")
113
- .option("-s, --src-pattern <pattern>", "Source file pattern for extraction", "src/**/!(*.d).{ts,tsx}")
114
- .option("-t, --poeditor-api-token <token>", "POEditor API token (can also use POEDITOR_API_TOKEN env var)")
115
- .option("-p, --poeditor-project-id <id>", "POEditor project ID", value => parseInt(value, 10))
116
- .action(async (options) => {
117
- const parsedOptions = diff_1.diffCommandOptionsSchema.extend(translationsServiceOptionsSchema.shape).parse(options);
118
- const config = (0, mergeWithEnv_1.mergeWithEnv)(parsedOptions);
119
- const translationsServiceClient = (0, mkTranslationsServiceClient_1.mkTranslationsServiceClient)({
120
- poeditorApiToken: config.poeditorApiToken,
121
- poeditorProjectId: config.poeditorProjectId,
122
- });
123
- await (0, diff_1.diff)({
124
- srcPattern: config.srcPattern,
125
- translationsServiceClient,
126
- });
127
- });
128
- commander_1.program.parse();
129
- //# sourceMappingURL=bin.js.map
package/src/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../../packages/intl/src/bin.ts"],"names":[],"mappings":";;;AAEA,yCAAmC;AACnC,+BAA0B;AAC1B,0CAAgE;AAChE,kDAA4E;AAC5E,4CAAmE;AACnE,0CAAgE;AAChE,8CAAsE;AACtE,iDAA6C;AAC7C,+EAA2E;AAE3E,MAAM,gCAAgC,GAAG,MAAC,CAAC,MAAM,CAAC;IAChD,gBAAgB,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACvC,iBAAiB,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAA;AAEF,mBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,uEAAuE,CAAC,CAAA;AAEzG,mBAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,uFAAuF,CAAC;KACpG,MAAM,CAAC,6BAA6B,EAAE,oCAAoC,EAAE,wBAAwB,CAAC;KACrG,MAAM,CAAC,wBAAwB,EAAE,4CAA4C,EAAE,MAAM,CAAC;KACtF,MAAM,CAAC,+BAA+B,EAAE,mCAAmC,CAAC;KAC5E,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AS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,yBAAyB;QACzB,eAAe,EAAE,MAAM,CAAC,eAAe;KACxC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ,mBAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,mEAAmE,CAAC;KAChF,MAAM,CAAC,6BAA6B,EAAE,oCAAoC,EAAE,wBAAwB,CAAC;KACrG,MAAM,CAAC,kCAAkC,EAAE,8DAA8D,CAAC;KAC1G,MAAM,CAAC,gCAAgC,EAAE,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAC7F,MAAM,CAAC,KAAK,EAAE,OAAgB,EAAE,EAAE;IACjC,MAAM,aAAa,GAAG,+BAAwB,CAAC,MAAM,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAE5G,MAAM,MAAM,GAAG,IAAA,2BAAY,EAAC,aAAa,CAAC,CAAA;IAE1C,MAAM,yBAAyB,GAAG,IAAA,yDAA2B,EAAC;QAC5D,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KAC5C,CAAC,CAAA;IAEF,MAAM,IAAA,WAAI,EAAC;QACT,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,yBAAyB;KAC1B,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ,mBAAO,CAAC,KAAK,EAAE,CAAA"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.diffCommandOptionsSchema = void 0;
4
- exports.diff = diff;
5
- const v4_1 = require("zod/v4");
6
- const formatjs_1 = require("../formatjs");
7
- exports.diffCommandOptionsSchema = v4_1.z.object({
8
- srcPattern: v4_1.z.string(),
9
- });
10
- async function diff({ srcPattern, translationsServiceClient }) {
11
- try {
12
- console.log("Analyzing differences between local and remote translations...");
13
- console.log("Extracting local messages...");
14
- const localMessages = (0, formatjs_1.extractMessages)(srcPattern);
15
- const localTerms = new Set(Object.keys(localMessages));
16
- console.log("Fetching remote terms...");
17
- const remoteTerms = await translationsServiceClient.downloadTerms();
18
- const remoteTermSet = new Set(remoteTerms.map(term => term.term));
19
- const unusedInLocal = [...remoteTermSet].filter(term => !localTerms.has(term));
20
- if (unusedInLocal.length > 0) {
21
- console.log(`\nTerms in remote but not used locally (${unusedInLocal.length}):`);
22
- unusedInLocal.forEach(term => {
23
- console.log(` - ${term}`);
24
- });
25
- }
26
- else {
27
- console.log("\nNo unused terms found in remote");
28
- }
29
- }
30
- catch (error) {
31
- console.error("Error in diff command:", error);
32
- process.exit(1);
33
- }
34
- }
35
- //# sourceMappingURL=diff.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../../../packages/intl/src/commands/diff.ts"],"names":[],"mappings":";;;AAYA,oBAyBC;AArCD,+BAA0B;AAC1B,0CAA6C;AAGhC,QAAA,wBAAwB,GAAG,MAAC,CAAC,MAAM,CAAC;IAC/C,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAA;AAMK,KAAK,UAAU,IAAI,CAAC,EAAE,UAAU,EAAE,yBAAyB,EAAsB;IACtF,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAA;QAE7E,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC3C,MAAM,aAAa,GAAG,IAAA,0BAAe,EAAC,UAAU,CAAC,CAAA;QACjD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;QAEtD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;QACvC,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAC,aAAa,EAAE,CAAA;QACnE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAEjE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,2CAA2C,aAAa,CAAC,MAAM,IAAI,CAAC,CAAA;YAChF,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;YAC5B,CAAC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadCommandOptionsSchema = void 0;
4
- exports.download = download;
5
- const fs_1 = require("fs");
6
- const v4_1 = require("zod/v4");
7
- const formatjs_1 = require("../formatjs");
8
- exports.downloadCommandOptionsSchema = v4_1.z.object({
9
- outputDir: v4_1.z.string(),
10
- languages: v4_1.z.array(v4_1.z.string()),
11
- });
12
- async function download({ outputDir, languages, translationsServiceClient }) {
13
- try {
14
- console.log("Starting download from translation service...");
15
- console.log(`Downloading translations for languages: ${languages.join(", ")}`);
16
- const tempDir = (0, formatjs_1.createTranslationsTempDir)("download-");
17
- try {
18
- for (const language of languages) {
19
- console.log(`Downloading ${language} translations...`);
20
- const translations = await translationsServiceClient.downloadTranslations(language);
21
- (0, formatjs_1.writeTranslationsToTempDir)({ translations, language, tempDir });
22
- const translationCount = Object.keys(translations).length;
23
- console.log(`Downloaded ${translationCount} translations for ${language}`);
24
- }
25
- console.log("Compiling translations...");
26
- (0, fs_1.mkdirSync)(outputDir, { recursive: true });
27
- (0, formatjs_1.compileTranslations)({ inputDir: tempDir, outputDir });
28
- console.log(`Compiled translations saved to ${outputDir}`);
29
- }
30
- finally {
31
- (0, fs_1.rmSync)(tempDir, { recursive: true, force: true });
32
- }
33
- }
34
- catch (error) {
35
- console.error("Error in download command:", error);
36
- process.exit(1);
37
- }
38
- }
39
- //# sourceMappingURL=download.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download.js","sourceRoot":"","sources":["../../../../../packages/intl/src/commands/download.ts"],"names":[],"mappings":";;;AAcA,4BAiCC;AA/CD,2BAAsC;AACtC,+BAA0B;AAC1B,0CAAwG;AAG3F,QAAA,4BAA4B,GAAG,MAAC,CAAC,MAAM,CAAC;IACnD,SAAS,EAAE,MAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,MAAC,CAAC,KAAK,CAAC,MAAC,CAAC,MAAM,EAAE,CAAC;CAC/B,CAAC,CAAA;AAMK,KAAK,UAAU,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,yBAAyB,EAA0B;IACxG,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;QAE5D,OAAO,CAAC,GAAG,CAAC,2CAA2C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE9E,MAAM,OAAO,GAAG,IAAA,oCAAyB,EAAC,WAAW,CAAC,CAAA;QAEtD,IAAI,CAAC;YACH,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,eAAe,QAAQ,kBAAkB,CAAC,CAAA;gBAEtD,MAAM,YAAY,GAAG,MAAM,yBAAyB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAA;gBACnF,IAAA,qCAA0B,EAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;gBAE/D,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAA;gBACzD,OAAO,CAAC,GAAG,CAAC,cAAc,gBAAgB,qBAAqB,QAAQ,EAAE,CAAC,CAAA;YAC5E,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;YAExC,IAAA,cAAS,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAEzC,IAAA,8BAAmB,EAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;YAErD,OAAO,CAAC,GAAG,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAA;QAC5D,CAAC;gBAAS,CAAC;YACT,IAAA,WAAM,EAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localCommandOptionsSchema = void 0;
4
- exports.local = local;
5
- const tslib_1 = require("tslib");
6
- const fs_1 = require("fs");
7
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
8
- const path_1 = require("path");
9
- const v4_1 = require("zod/v4");
10
- const formatjs_1 = require("../formatjs");
11
- exports.localCommandOptionsSchema = v4_1.z.object({
12
- srcPattern: v4_1.z.string(),
13
- outputDir: v4_1.z.string(),
14
- defaultLanguage: v4_1.z.string(),
15
- });
16
- async function local({ defaultLanguage, outputDir, srcPattern, translationsServiceClient, }) {
17
- try {
18
- const extractedTranslations = extractAndCompile({ srcPattern, defaultLanguage });
19
- const downloadedTranslations = translationsServiceClient
20
- ? await downloadAndCompile({ defaultLanguage, client: translationsServiceClient })
21
- : undefined;
22
- const translations = mergeTranslations({ extractedTranslations, downloadedTranslations });
23
- save({ translations, outputDir, defaultLanguage });
24
- }
25
- catch (error) {
26
- console.error("Error in local command:", error);
27
- process.exit(1);
28
- }
29
- }
30
- function extractAndCompile({ srcPattern, defaultLanguage, }) {
31
- console.log("Extracting messages from source files...");
32
- const messages = (0, formatjs_1.extractMessages)(srcPattern);
33
- const messageCount = Object.keys(messages).length;
34
- console.log(`Extracted ${messageCount} messages`);
35
- if (messageCount === 0) {
36
- console.log("No messages found. Make sure your source files contain formatjs messages.");
37
- throw new Error("No messages found");
38
- }
39
- const tempDir = (0, formatjs_1.createTranslationsTempDir)("local-");
40
- try {
41
- const extractedTranslations = {};
42
- for (const [id, details] of Object.entries(messages)) {
43
- extractedTranslations[id] = details.defaultMessage;
44
- }
45
- (0, formatjs_1.writeTranslationsToTempDir)({ translations: extractedTranslations, language: defaultLanguage, tempDir });
46
- console.log("Compiling extracted translations...");
47
- const tempOutputDir = (0, formatjs_1.createTranslationsTempDir)("compiled-");
48
- try {
49
- (0, formatjs_1.compileTranslations)({ inputDir: tempDir, outputDir: tempOutputDir });
50
- const compiledFilePath = (0, path_1.join)(tempOutputDir, `${defaultLanguage}.json`);
51
- const compiledContent = (0, fs_1.readFileSync)(compiledFilePath, "utf-8");
52
- return JSON.parse(compiledContent);
53
- }
54
- finally {
55
- (0, fs_1.rmSync)(tempOutputDir, { recursive: true, force: true });
56
- }
57
- }
58
- finally {
59
- (0, fs_1.rmSync)(tempDir, { recursive: true, force: true });
60
- }
61
- }
62
- async function downloadAndCompile({ defaultLanguage, client, }) {
63
- try {
64
- console.log(`Downloading ${defaultLanguage} translations...`);
65
- const downloadedTranslations = await client.downloadTranslations(defaultLanguage);
66
- const downloadedCount = Object.keys(downloadedTranslations).length;
67
- console.log(`Downloaded ${downloadedCount} translations`);
68
- if (downloadedCount === 0) {
69
- return undefined;
70
- }
71
- const downloadTempDir = (0, formatjs_1.createTranslationsTempDir)("download-");
72
- try {
73
- (0, formatjs_1.writeTranslationsToTempDir)({
74
- translations: downloadedTranslations,
75
- language: defaultLanguage,
76
- tempDir: downloadTempDir,
77
- });
78
- console.log("Compiling downloaded translations...");
79
- const downloadTempOutputDir = (0, formatjs_1.createTranslationsTempDir)("download-compiled-");
80
- try {
81
- (0, formatjs_1.compileTranslations)({ inputDir: downloadTempDir, outputDir: downloadTempOutputDir });
82
- const downloadedCompiledFilePath = (0, path_1.join)(downloadTempOutputDir, `${defaultLanguage}.json`);
83
- const downloadedCompiledContent = (0, fs_1.readFileSync)(downloadedCompiledFilePath, "utf-8");
84
- return JSON.parse(downloadedCompiledContent);
85
- }
86
- finally {
87
- (0, fs_1.rmSync)(downloadTempOutputDir, { recursive: true, force: true });
88
- }
89
- }
90
- finally {
91
- (0, fs_1.rmSync)(downloadTempDir, { recursive: true, force: true });
92
- }
93
- }
94
- catch (error) {
95
- console.warn(`Failed to download translations from translation service: ${error}`);
96
- console.log("Using extracted translations only");
97
- return undefined;
98
- }
99
- }
100
- function mergeTranslations({ extractedTranslations, downloadedTranslations, }) {
101
- if (!downloadedTranslations) {
102
- return extractedTranslations;
103
- }
104
- const finalTranslations = { ...extractedTranslations, ...downloadedTranslations };
105
- const newTranslationsCount = Object.keys(extractedTranslations).filter(key => !(key in downloadedTranslations)).length;
106
- const downloadedTranslationsCount = Object.keys(downloadedTranslations).length;
107
- console.log(`Merged ${newTranslationsCount} extracted terms with ${downloadedTranslationsCount} downloaded translations`);
108
- return finalTranslations;
109
- }
110
- function save({ translations, outputDir, defaultLanguage, }) {
111
- (0, fs_1.mkdirSync)(outputDir, { recursive: true });
112
- const sortedTranslations = (0, lodash_1.default)(translations).toPairs().sortBy(0).fromPairs().value();
113
- const finalFilePath = (0, path_1.join)(outputDir, `${defaultLanguage}.json`);
114
- (0, fs_1.writeFileSync)(finalFilePath, JSON.stringify(sortedTranslations, null, 2));
115
- console.log(`Merged translations saved to ${outputDir}`);
116
- }
117
- //# sourceMappingURL=local.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../packages/intl/src/commands/local.ts"],"names":[],"mappings":";;;AAsBA,sBAoBC;;AA1CD,2BAAmE;AACnE,4DAAsB;AACtB,+BAA2B;AAC3B,+BAA0B;AAC1B,0CAKoB;AAGP,QAAA,yBAAyB,GAAG,MAAC,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,MAAC,CAAC,MAAM,EAAE;IACrB,eAAe,EAAE,MAAC,CAAC,MAAM,EAAE;CAC5B,CAAC,CAAA;AAMK,KAAK,UAAU,KAAK,CAAC,EAC1B,eAAe,EACf,SAAS,EACT,UAAU,EACV,yBAAyB,GACL;IACpB,IAAI,CAAC;QACH,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAA;QAEhF,MAAM,sBAAsB,GAAG,yBAAyB;YACtD,CAAC,CAAC,MAAM,kBAAkB,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;YAClF,CAAC,CAAC,SAAS,CAAA;QAEb,MAAM,YAAY,GAAG,iBAAiB,CAAC,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC,CAAA;QAEzF,IAAI,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAA;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;QAC/C,O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B,CAAC,CAAC,MAAM,CAAA;IAC9E,OAAO,CAAC,GAAG,CACT,UAAU,oBAAoB,yBAAyB,2BAA2B,0BAA0B,CAC7G,CAAA;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAED,SAAS,IAAI,CAAC,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,GAKhB;IACC,IAAA,cAAS,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAEzC,MAAM,kBAAkB,GAAG,IAAA,gBAAC,EAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAA;IAElF,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,GAAG,eAAe,OAAO,CAAC,CAAA;IAChE,IAAA,kBAAa,EAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAEzE,OAAO,CAAC,GAAG,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAA;AAC1D,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncCommandOptionsSchema = void 0;
4
- exports.sync = sync;
5
- const v4_1 = require("zod/v4");
6
- const download_1 = require("./download");
7
- const upload_1 = require("./upload");
8
- exports.syncCommandOptionsSchema = v4_1.z.object({
9
- srcPattern: v4_1.z.string(),
10
- outputDir: v4_1.z.string(),
11
- languages: v4_1.z.array(v4_1.z.string()),
12
- defaultLanguage: v4_1.z.string(),
13
- });
14
- async function sync({ srcPattern, outputDir, languages, translationsServiceClient, defaultLanguage, }) {
15
- try {
16
- console.log("Starting sync operation...");
17
- await (0, upload_1.upload)({
18
- srcPattern,
19
- translationsServiceClient,
20
- defaultLanguage,
21
- });
22
- await (0, download_1.download)({
23
- outputDir,
24
- languages,
25
- translationsServiceClient,
26
- });
27
- console.log("Sync completed successfully!");
28
- }
29
- catch (error) {
30
- console.error("Error in sync command:", error);
31
- process.exit(1);
32
- }
33
- }
34
- //# sourceMappingURL=sync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../../packages/intl/src/commands/sync.ts"],"names":[],"mappings":";;;AAgBA,oBA2BC;AA3CD,+BAA0B;AAC1B,yCAAqC;AACrC,qCAAiC;AAGpB,QAAA,wBAAwB,GAAG,MAAC,CAAC,MAAM,CAAC;IAC/C,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,MAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,MAAC,CAAC,KAAK,CAAC,MAAC,CAAC,MAAM,EAAE,CAAC;IAC9B,eAAe,EAAE,MAAC,CAAC,MAAM,EAAE;CAC5B,CAAC,CAAA;AAMK,KAAK,UAAU,IAAI,CAAC,EACzB,UAAU,EACV,SAAS,EACT,SAAS,EACT,yBAAyB,EACzB,eAAe,GACI;IACnB,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;QAEzC,MAAM,IAAA,eAAM,EAAC;YACX,UAAU;YACV,yBAAyB;YACzB,eAAe;SAChB,CAAC,CAAA;QAEF,MAAM,IAAA,mBAAQ,EAAC;YACb,SAAS;YACT,SAAS;YACT,yBAAyB;SAC1B,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadCommandOptionsSchema = void 0;
4
- exports.upload = upload;
5
- const v4_1 = require("zod/v4");
6
- const formatjs_1 = require("../formatjs");
7
- exports.uploadCommandOptionsSchema = v4_1.z.object({
8
- srcPattern: v4_1.z.string(),
9
- defaultLanguage: v4_1.z.string(),
10
- });
11
- async function upload({ srcPattern, translationsServiceClient, defaultLanguage }) {
12
- try {
13
- console.log("Extracting messages from source files...");
14
- const messages = (0, formatjs_1.extractMessages)(srcPattern);
15
- const messageCount = Object.keys(messages).length;
16
- console.log(`Extracted ${messageCount} messages`);
17
- if (messageCount === 0) {
18
- console.log("No messages found. Make sure your source files contain formatjs messages.");
19
- return;
20
- }
21
- console.log("Uploading terms to translation service...");
22
- await translationsServiceClient.uploadTerms(messages);
23
- console.log(`Uploading default translations (${defaultLanguage}) to translation service...`);
24
- await translationsServiceClient.uploadTranslations(messages, defaultLanguage);
25
- console.log("Upload completed successfully!");
26
- }
27
- catch (error) {
28
- console.error("Error in upload command:", error);
29
- process.exit(1);
30
- }
31
- }
32
- //# sourceMappingURL=upload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../../../packages/intl/src/commands/upload.ts"],"names":[],"mappings":";;;AAaA,wBA2BC;AAxCD,+BAA0B;AAC1B,0CAA6C;AAGhC,QAAA,0BAA0B,GAAG,MAAC,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE;IACtB,eAAe,EAAE,MAAC,CAAC,MAAM,EAAE;CAC5B,CAAC,CAAA;AAMK,KAAK,UAAU,MAAM,CAAC,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAwB;IAC3G,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;QAEvD,MAAM,QAAQ,GAAG,IAAA,0BAAe,EAAC,UAAU,CAAC,CAAA;QAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;QAEjD,OAAO,CAAC,GAAG,CAAC,aAAa,YAAY,WAAW,CAAC,CAAA;QAEjD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAA;YACxF,OAAM;QACR,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;QAExD,MAAM,yBAAyB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAErD,OAAO,CAAC,GAAG,CAAC,mCAAmC,eAAe,6BAA6B,CAAC,CAAA;QAE5F,MAAM,yBAAyB,CAAC,kBAAkB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;QAE7E,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
package/src/formatjs.js DELETED
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractMessages = extractMessages;
4
- exports.compileTranslations = compileTranslations;
5
- exports.createTranslationsTempDir = createTranslationsTempDir;
6
- exports.writeTranslationsToTempDir = writeTranslationsToTempDir;
7
- const child_process_1 = require("child_process");
8
- const fs_1 = require("fs");
9
- const os_1 = require("os");
10
- const path_1 = require("path");
11
- function extractMessages(pattern = "src/**/*.{ts,tsx}") {
12
- const tempFile = (0, path_1.join)((0, os_1.tmpdir)(), `messages-${Date.now()}.json`);
13
- try {
14
- const command = [
15
- "npx",
16
- "@formatjs/cli",
17
- "extract",
18
- `"${pattern}"`,
19
- "--out-file",
20
- `"${tempFile}"`,
21
- "--preserve-whitespace",
22
- "--extract-source-location",
23
- ].join(" ");
24
- (0, child_process_1.execSync)(command);
25
- const messagesText = (0, fs_1.readFileSync)(tempFile, "utf-8");
26
- (0, fs_1.rmSync)(tempFile);
27
- return JSON.parse(messagesText);
28
- }
29
- catch (error) {
30
- throw new Error(`Failed to extract messages. Error: ${error}`);
31
- }
32
- }
33
- function compileTranslations({ inputDir, outputDir, options = {}, }) {
34
- const { ast = true, format = "simple" } = options;
35
- try {
36
- const command = [
37
- "npx",
38
- "@formatjs/cli",
39
- "compile-folder",
40
- ...(ast ? ["--ast"] : []),
41
- "--format",
42
- format,
43
- inputDir,
44
- outputDir,
45
- ].join(" ");
46
- (0, child_process_1.execSync)(command);
47
- }
48
- catch (error) {
49
- throw new Error(`Failed to compile translations. Error: ${error}`);
50
- }
51
- }
52
- function createTranslationsTempDir(prefix = "intl-") {
53
- return (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), prefix));
54
- }
55
- function writeTranslationsToTempDir({ translations, language, tempDir, }) {
56
- const filePath = (0, path_1.join)(tempDir, `${language}.json`);
57
- (0, fs_1.writeFileSync)(filePath, JSON.stringify(translations, null, 2));
58
- return filePath;
59
- }
60
- //# sourceMappingURL=formatjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatjs.js","sourceRoot":"","sources":["../../../../packages/intl/src/formatjs.ts"],"names":[],"mappings":";;AAaA,0CAuBC;AAED,kDA0BC;AAED,8DAEC;AAED,gEAYC;AAlFD,iDAAwC;AACxC,2BAAqE;AACrE,2BAA2B;AAC3B,+BAA2B;AAU3B,SAAgB,eAAe,CAAC,OAAO,GAAG,mBAAmB;IAC3D,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAE9D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG;YACd,KAAK;YACL,eAAe;YACf,SAAS;YACT,IAAI,OAAO,GAAG;YACd,YAAY;YACZ,IAAI,QAAQ,GAAG;YACf,uBAAuB;YACvB,2BAA2B;SAC5B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAEX,IAAA,wBAAQ,E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BAAa,EAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9D,OAAO,QAAQ,CAAA;AACjB,CAAC"}
package/src/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { diff } from "./commands/diff";
2
- export { download } from "./commands/download";
3
- export { local } from "./commands/local";
4
- export { sync } from "./commands/sync";
5
- export { upload } from "./commands/upload";
6
- export { mkTranslationsServiceClient } from "./mkTranslationsServiceClient";
package/src/index.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mkTranslationsServiceClient = exports.upload = exports.sync = exports.local = exports.download = exports.diff = void 0;
4
- var diff_1 = require("./commands/diff");
5
- Object.defineProperty(exports, "diff", { enumerable: true, get: function () { return diff_1.diff; } });
6
- var download_1 = require("./commands/download");
7
- Object.defineProperty(exports, "download", { enumerable: true, get: function () { return download_1.download; } });
8
- var local_1 = require("./commands/local");
9
- Object.defineProperty(exports, "local", { enumerable: true, get: function () { return local_1.local; } });
10
- var sync_1 = require("./commands/sync");
11
- Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return sync_1.sync; } });
12
- var upload_1 = require("./commands/upload");
13
- Object.defineProperty(exports, "upload", { enumerable: true, get: function () { return upload_1.upload; } });
14
- var mkTranslationsServiceClient_1 = require("./mkTranslationsServiceClient");
15
- Object.defineProperty(exports, "mkTranslationsServiceClient", { enumerable: true, get: function () { return mkTranslationsServiceClient_1.mkTranslationsServiceClient; } });
16
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/intl/src/index.ts"],"names":[],"mappings":";;;AAAA,wCAAsC;AAA7B,4FAAA,IAAI,OAAA;AACb,gDAA8C;AAArC,oGAAA,QAAQ,OAAA;AACjB,0CAAwC;AAA/B,8FAAA,KAAK,OAAA;AACd,wCAAsC;AAA7B,4FAAA,IAAI,OAAA;AACb,4CAA0C;AAAjC,gGAAA,MAAM,OAAA;AACf,6EAA2E;AAAlE,0IAAA,2BAA2B,OAAA"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeWithEnv = mergeWithEnv;
4
- function mergeWithEnv(options) {
5
- const poeditorApiToken = options.poeditorApiToken || process.env["POEDITOR_API_TOKEN"];
6
- const poeditorProjectId = options.poeditorProjectId ||
7
- (process.env["POEDITOR_PROJECT_ID"] ? parseInt(process.env["POEDITOR_PROJECT_ID"], 10) : undefined);
8
- return {
9
- ...options,
10
- poeditorApiToken,
11
- poeditorProjectId,
12
- };
13
- }
14
- //# sourceMappingURL=mergeWithEnv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeWithEnv.js","sourceRoot":"","sources":["../../../../packages/intl/src/mergeWithEnv.ts"],"names":[],"mappings":";;AAAA,oCAaC;AAbD,SAAgB,YAAY,CAC1B,OAAU;IAEV,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACtF,MAAM,iBAAiB,GACrB,OAAO,CAAC,iBAAiB;QACzB,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAErG,OAAO;QACL,GAAG,OAAO;QACV,gBAAgB;QAChB,iBAAiB;KAClB,CAAA;AACH,CAAC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mkTranslationsServiceClient = mkTranslationsServiceClient;
4
- const POEditorClient_1 = require("./poeditor/POEditorClient");
5
- function mkTranslationsServiceClient({ poeditorApiToken, poeditorProjectId, }) {
6
- if (!!poeditorApiToken && !!poeditorProjectId) {
7
- return new POEditorClient_1.POEditorClient({
8
- apiToken: poeditorApiToken,
9
- projectId: poeditorProjectId,
10
- });
11
- }
12
- throw new Error("No configuration for translations service client provided.");
13
- }
14
- //# sourceMappingURL=mkTranslationsServiceClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mkTranslationsServiceClient.js","sourceRoot":"","sources":["../../../../packages/intl/src/mkTranslationsServiceClient.ts"],"names":[],"mappings":";;AAGA,kEAeC;AAlBD,8DAA0D;AAG1D,SAAgB,2BAA2B,CAAC,EAC1C,gBAAgB,EAChB,iBAAiB,GAIlB;IACC,IAAI,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC9C,OAAO,IAAI,+BAAc,CAAC;YACxB,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE,iBAAiB;SAC7B,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;AAC/E,CAAC"}