auto-translate-json-library 1.1.5 → 1.2.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/lib.js CHANGED
@@ -1,162 +1,166 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.translate = void 0;
13
- // The module 'vscode' contains the VS Code extensibility API
14
- // Import the module and reference it with the alias vscode in your code below
15
- const files_1 = require("./files");
16
- const folderFiles_1 = require("./folderFiles");
17
- const aws_1 = require("./aws");
18
- const azure_1 = require("./azure");
19
- const google_1 = require("./google");
20
- const util_1 = require("./util");
21
- const deepl_1 = require("./deepl");
22
- const NAME = 'AutoTranslateJSON';
23
- function translate(sourceFile, config) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- // set the delimiters for named arguments
26
- const startDelimiter = config.startDelimiter || '{';
27
- if (startDelimiter) {
28
- util_1.Util.startDelimiter = startDelimiter;
29
- }
30
- const endDelimiter = config.endDelimiter || '}';
31
- if (endDelimiter) {
32
- util_1.Util.endDelimiter = endDelimiter;
33
- }
34
- let translateEngine;
35
- if (config.translationKeyInfo.kind === 'google') {
36
- translateEngine = new google_1.GoogleTranslate(config.translationKeyInfo.apiKey);
37
- }
38
- else if (config.translationKeyInfo.kind === 'aws') {
39
- translateEngine = new aws_1.AWSTranslate(config.translationKeyInfo.accessKeyId, config.translationKeyInfo.secretAccessKey, config.translationKeyInfo.region);
40
- }
41
- else if (config.translationKeyInfo.kind === 'azure') {
42
- translateEngine = new azure_1.AzureTranslate(config.translationKeyInfo.secretKey, config.translationKeyInfo.region);
43
- }
44
- else if (config.translationKeyInfo.kind === 'deepLFree') {
45
- translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, 'free');
46
- }
47
- else if (config.translationKeyInfo.kind === 'deepLPro') {
48
- translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, 'pro');
49
- }
50
- else {
51
- console.warn('You must provide a Google, AWS or Azure parameters first in the extension settings.');
52
- return;
53
- }
54
- const fileMode = config.mode;
55
- const files = readFiles(sourceFile, fileMode);
56
- if (files === null) {
57
- return;
58
- }
59
- // enforce source locale if provided in settings
60
- if (config.sourceLocale !== files.sourceLocale) {
61
- console.log('You must use the ' +
62
- config.sourceLocale +
63
- '.json file due to your Source Locale setting.');
64
- return;
65
- }
66
- const keepTranslations = config.keepTranslations === 'keep';
67
- const keepExtras = config.keepExtraTranslations === 'keep';
68
- // load source JSON
69
- let source;
70
- try {
71
- source = yield files.loadJsonFromLocale(files.sourceLocale);
72
- }
73
- catch (error) {
74
- if (error instanceof Error) {
75
- console.log(error, 'Source file malformed');
76
- }
77
- return;
78
- }
79
- // Iterate target Locales
80
- files.targetLocales.forEach((targetLocale) => __awaiter(this, void 0, void 0, function* () {
81
- try {
82
- const isValid = yield translateEngine.isValidLocale(targetLocale);
83
- if (!isValid) {
84
- throw Error(targetLocale + ' is not supported. Skipping.');
85
- }
86
- const targetOriginal = yield files.loadJsonFromLocale(targetLocale);
87
- // Iterate source terms
88
- const targetNew = yield recurseNode(source, targetOriginal, keepTranslations, keepExtras, files.sourceLocale, targetLocale, translateEngine);
89
- // save target
90
- files.saveJsonToLocale(targetLocale, targetNew);
91
- const feedback = "Translated locale '" + targetLocale + "'";
92
- console.log(feedback);
93
- }
94
- catch (error) {
95
- if (error instanceof Error) {
96
- console.error(error);
97
- }
98
- return;
99
- }
100
- }));
101
- });
102
- }
103
- exports.translate = translate;
104
- const readFiles = (filePath, mode) => {
105
- try {
106
- const files = mode === 'file' ? new files_1.Files(filePath) : new folderFiles_1.FolderFiles(filePath);
107
- // log locale info
108
- console.log('Source locale = ' + files.sourceLocale);
109
- console.log('Target locales = ' + files.targetLocales);
110
- return files;
111
- }
112
- catch (error) {
113
- if (error instanceof Error) {
114
- console.error(error);
115
- }
116
- return null;
117
- }
118
- };
119
- function recurseNode(source, original, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, isArray = false) {
120
- var _a;
121
- return __awaiter(this, void 0, void 0, function* () {
122
- const destination = isArray ? [] : {};
123
- // defaults
124
- if (keepTranslations === null) {
125
- keepTranslations = true;
126
- }
127
- if (keepExtras === null) {
128
- keepExtras = true;
129
- }
130
- for (const term in source) {
131
- const node = source[term];
132
- if (node instanceof Object && node !== null) {
133
- destination[term] = yield recurseNode(node, (_a = original[term]) !== null && _a !== void 0 ? _a : {}, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, node instanceof Array);
134
- }
135
- else {
136
- // if we already have a translation, keep it
137
- if (keepTranslations && original[term]) {
138
- destination[term] = original[term];
139
- }
140
- else if (typeof node === 'number' || typeof node === 'boolean') {
141
- // numbers and booleans do not need translations
142
- destination[term] = node;
143
- }
144
- else {
145
- const translation = yield translateEngine
146
- .translateText(node, sourceLocale, locale)
147
- .catch((err) => console.error(err));
148
- destination[term] = translation;
149
- }
150
- }
151
- }
152
- if (keepExtras) {
153
- // add back in any terms that were not in source
154
- for (const term in original) {
155
- if (!destination[term]) {
156
- destination[term] = original[term];
157
- }
158
- }
159
- }
160
- return destination;
161
- });
162
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.translate = void 0;
13
+ // The module 'vscode' contains the VS Code extensibility API
14
+ // Import the module and reference it with the alias vscode in your code below
15
+ const files_1 = require("./files");
16
+ const folderFiles_1 = require("./folderFiles");
17
+ const aws_1 = require("./aws");
18
+ const azure_1 = require("./azure");
19
+ const google_1 = require("./google");
20
+ const util_1 = require("./util");
21
+ const deepl_1 = require("./deepl");
22
+ const openai_1 = require("./openai");
23
+ const NAME = 'AutoTranslateJSON';
24
+ function translate(sourceFile, config) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ // set the delimiters for named arguments
27
+ const startDelimiter = config.startDelimiter || '{';
28
+ if (startDelimiter) {
29
+ util_1.Util.startDelimiter = startDelimiter;
30
+ }
31
+ const endDelimiter = config.endDelimiter || '}';
32
+ if (endDelimiter) {
33
+ util_1.Util.endDelimiter = endDelimiter;
34
+ }
35
+ let translateEngine;
36
+ if (config.translationKeyInfo.kind === 'google') {
37
+ translateEngine = new google_1.GoogleTranslate(config.translationKeyInfo.apiKey);
38
+ }
39
+ else if (config.translationKeyInfo.kind === 'aws') {
40
+ translateEngine = new aws_1.AWSTranslate(config.translationKeyInfo.accessKeyId, config.translationKeyInfo.secretAccessKey, config.translationKeyInfo.region);
41
+ }
42
+ else if (config.translationKeyInfo.kind === 'azure') {
43
+ translateEngine = new azure_1.AzureTranslate(config.translationKeyInfo.secretKey, config.translationKeyInfo.region);
44
+ }
45
+ else if (config.translationKeyInfo.kind === 'deepLFree') {
46
+ translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, 'free');
47
+ }
48
+ else if (config.translationKeyInfo.kind === 'deepLPro') {
49
+ translateEngine = new deepl_1.DeepLTranslate(config.translationKeyInfo.secretKey, 'pro');
50
+ }
51
+ else if (config.translationKeyInfo.kind === 'openai') {
52
+ translateEngine = new openai_1.OpenAITranslate(config.translationKeyInfo.apiKey);
53
+ }
54
+ else {
55
+ console.warn('You must provide a Google, AWS, Azure, deepL, openai parameters first in the extension settings.');
56
+ return;
57
+ }
58
+ const fileMode = config.mode;
59
+ const files = readFiles(sourceFile, fileMode);
60
+ if (files === null) {
61
+ return;
62
+ }
63
+ // enforce source locale if provided in settings
64
+ if (config.sourceLocale !== files.sourceLocale) {
65
+ console.log('You must use the ' +
66
+ config.sourceLocale +
67
+ '.json file due to your Source Locale setting.');
68
+ return;
69
+ }
70
+ const keepTranslations = config.keepTranslations === 'keep';
71
+ const keepExtras = config.keepExtraTranslations === 'keep';
72
+ // load source JSON
73
+ let source;
74
+ try {
75
+ source = yield files.loadJsonFromLocale(files.sourceLocale);
76
+ }
77
+ catch (error) {
78
+ if (error instanceof Error) {
79
+ console.log(error, 'Source file malformed');
80
+ }
81
+ return;
82
+ }
83
+ // Iterate target Locales
84
+ files.targetLocales.forEach((targetLocale) => __awaiter(this, void 0, void 0, function* () {
85
+ try {
86
+ const isValid = yield translateEngine.isValidLocale(targetLocale);
87
+ if (!isValid) {
88
+ throw Error(targetLocale + ' is not supported. Skipping.');
89
+ }
90
+ const targetOriginal = yield files.loadJsonFromLocale(targetLocale);
91
+ // Iterate source terms
92
+ const targetNew = yield recurseNode(source, targetOriginal, keepTranslations, keepExtras, files.sourceLocale, targetLocale, translateEngine);
93
+ // save target
94
+ files.saveJsonToLocale(targetLocale, targetNew);
95
+ const feedback = "Translated locale '" + targetLocale + "'";
96
+ console.log(feedback);
97
+ }
98
+ catch (error) {
99
+ if (error instanceof Error) {
100
+ console.error(error);
101
+ }
102
+ return;
103
+ }
104
+ }));
105
+ });
106
+ }
107
+ exports.translate = translate;
108
+ const readFiles = (filePath, mode) => {
109
+ try {
110
+ const files = mode === 'file' ? new files_1.Files(filePath) : new folderFiles_1.FolderFiles(filePath);
111
+ // log locale info
112
+ console.log('Source locale = ' + files.sourceLocale);
113
+ console.log('Target locales = ' + files.targetLocales);
114
+ return files;
115
+ }
116
+ catch (error) {
117
+ if (error instanceof Error) {
118
+ console.error(error);
119
+ }
120
+ return null;
121
+ }
122
+ };
123
+ function recurseNode(source, original, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, isArray = false) {
124
+ var _a;
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const destination = isArray ? [] : {};
127
+ // defaults
128
+ if (keepTranslations === null) {
129
+ keepTranslations = true;
130
+ }
131
+ if (keepExtras === null) {
132
+ keepExtras = true;
133
+ }
134
+ for (const term in source) {
135
+ const node = source[term];
136
+ if (node instanceof Object && node !== null) {
137
+ destination[term] = yield recurseNode(node, (_a = original[term]) !== null && _a !== void 0 ? _a : {}, keepTranslations, keepExtras, sourceLocale, locale, translateEngine, node instanceof Array);
138
+ }
139
+ else {
140
+ // if we already have a translation, keep it
141
+ if (keepTranslations && original[term]) {
142
+ destination[term] = original[term];
143
+ }
144
+ else if (typeof node === 'number' || typeof node === 'boolean') {
145
+ // numbers and booleans do not need translations
146
+ destination[term] = node;
147
+ }
148
+ else {
149
+ const translation = yield translateEngine
150
+ .translateText(node, sourceLocale, locale)
151
+ .catch((err) => console.error(err));
152
+ destination[term] = translation;
153
+ }
154
+ }
155
+ }
156
+ if (keepExtras) {
157
+ // add back in any terms that were not in source
158
+ for (const term in original) {
159
+ if (!destination[term]) {
160
+ destination[term] = original[term];
161
+ }
162
+ }
163
+ }
164
+ return destination;
165
+ });
166
+ }
package/openai.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ITranslate } from "./translate.interface";
2
+ export declare class OpenAITranslate implements ITranslate {
3
+ private apiKey;
4
+ private endpoint;
5
+ private openai;
6
+ constructor(apiKey: string);
7
+ isValidLocale(targetLocale: string): boolean;
8
+ translateText(text: string, sourceLocale: string, targetLocale: string): Promise<string>;
9
+ }
package/openai.js ADDED
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OpenAITranslate = void 0;
13
+ const util_1 = require("./util");
14
+ const openai_1 = require("openai");
15
+ const supportedLanguages = {
16
+ 'af': 'Afrikaans',
17
+ 'sq': 'Albanian',
18
+ 'am': 'Amharic',
19
+ 'ar': 'Arabic',
20
+ 'hy': 'Armenian',
21
+ 'az': 'Azerbaijani',
22
+ 'eu': 'Basque',
23
+ 'be': 'Belarusian',
24
+ 'bn': 'Bengali',
25
+ 'bs': 'Bosnian',
26
+ 'bg': 'Bulgarian',
27
+ 'ca': 'Catalan',
28
+ 'ceb': 'Cebuano',
29
+ 'zh-CN': 'Chinese (Simplified)',
30
+ 'zh-TW': 'Chinese (Traditional)',
31
+ 'co': 'Corsican',
32
+ 'hr': 'Croatian',
33
+ 'cs': 'Czech',
34
+ 'da': 'Danish',
35
+ 'nl': 'Dutch',
36
+ 'en': 'English',
37
+ 'eo': 'Esperanto',
38
+ 'et': 'Estonian',
39
+ 'fi': 'Finnish',
40
+ 'fr': 'French',
41
+ 'fy': 'Frisian',
42
+ 'gl': 'Galician',
43
+ 'ka': 'Georgian',
44
+ 'de': 'German',
45
+ 'el': 'Greek',
46
+ 'gu': 'Gujarati',
47
+ 'ht': 'Haitian Creole',
48
+ 'ha': 'Hausa',
49
+ 'haw': 'Hawaiian',
50
+ 'he': 'Hebrew',
51
+ 'hi': 'Hindi',
52
+ 'hmn': 'Hmong',
53
+ 'hu': 'Hungarian',
54
+ 'is': 'Icelandic',
55
+ 'ig': 'Igbo',
56
+ 'id': 'Indonesian',
57
+ 'ga': 'Irish',
58
+ 'it': 'Italian',
59
+ 'ja': 'Japanese',
60
+ 'jv': 'Javanese',
61
+ 'kn': 'Kannada',
62
+ 'kk': 'Kazakh',
63
+ 'km': 'Khmer',
64
+ 'ko': 'Korean',
65
+ 'ku': 'Kurdish',
66
+ 'ky': 'Kyrgyz',
67
+ 'lo': 'Lao',
68
+ 'la': 'Latin',
69
+ 'lv': 'Latvian',
70
+ 'lt': 'Lithuanian',
71
+ 'lb': 'Luxembourgish',
72
+ 'mk': 'Macedonian',
73
+ 'mg': 'Malagasy',
74
+ 'ms': 'Malay',
75
+ 'ml': 'Malayalam',
76
+ 'mt': 'Maltese',
77
+ 'mi': 'Maori',
78
+ 'mr': 'Marathi',
79
+ 'mn': 'Mongolian',
80
+ 'my': 'Myanmar (Burmese)',
81
+ 'ne': 'Nepali',
82
+ 'no': 'Norwegian',
83
+ 'ny': 'Nyanja (Chichewa)',
84
+ 'or': 'Odia (Oriya)',
85
+ 'ps': 'Pashto',
86
+ 'fa': 'Persian',
87
+ 'pl': 'Polish',
88
+ 'pt': 'Portuguese',
89
+ 'pa': 'Punjabi',
90
+ 'ro': 'Romanian',
91
+ 'ru': 'Russian',
92
+ 'sm': 'Samoan',
93
+ 'gd': 'Scots Gaelic',
94
+ 'sr': 'Serbian',
95
+ 'st': 'Sesotho',
96
+ 'sn': 'Shona',
97
+ 'sd': 'Sindhi',
98
+ 'si': 'Sinhala (Sinhalese)',
99
+ 'sk': 'Slovak',
100
+ 'sl': 'Slovenian',
101
+ 'so': 'Somali',
102
+ 'es': 'Spanish',
103
+ 'su': 'Sundanese',
104
+ 'sw': 'Swahili',
105
+ 'sv': 'Swedish',
106
+ 'tl': 'Tagalog (Filipino)',
107
+ 'tg': 'Tajik',
108
+ 'ta': 'Tamil',
109
+ 'tt': 'Tatar',
110
+ 'te': 'Telugu',
111
+ 'th': 'Thai',
112
+ 'tr': 'Turkish',
113
+ 'tk': 'Turkmen',
114
+ 'uk': 'Ukrainian',
115
+ 'ur': 'Urdu',
116
+ 'ug': 'Uyghur',
117
+ 'uz': 'Uzbek',
118
+ 'vi': 'Vietnamese',
119
+ 'cy': 'Welsh',
120
+ 'xh': 'Xhosa',
121
+ 'yi': 'Yiddish',
122
+ 'yo': 'Yoruba',
123
+ 'zu': 'Zulu'
124
+ };
125
+ class OpenAITranslate {
126
+ constructor(apiKey) {
127
+ this.apiKey = apiKey;
128
+ this.endpoint = 'https://api.cognitive.microsofttranslator.com';
129
+ const configuration = new openai_1.Configuration({
130
+ apiKey: apiKey,
131
+ });
132
+ this.openai = new openai_1.OpenAIApi(configuration);
133
+ }
134
+ isValidLocale(targetLocale) {
135
+ return targetLocale in supportedLanguages;
136
+ }
137
+ translateText(text, sourceLocale, targetLocale) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ if (sourceLocale !== 'en') {
140
+ throw Error(sourceLocale + ' is not supported.Currently we support just English ');
141
+ }
142
+ let result = '';
143
+ let args;
144
+ ({ args, text } = util_1.Util.replaceContextVariables(text));
145
+ const prompt = `Translate this into ${supportedLanguages[targetLocale]}:\n${text}\n.`;
146
+ const response = yield this.openai.createCompletion({
147
+ model: "text-davinci-003",
148
+ prompt: prompt,
149
+ temperature: 0.3,
150
+ max_tokens: 1000,
151
+ top_p: 1.0,
152
+ frequency_penalty: 0.0,
153
+ presence_penalty: 0.0,
154
+ });
155
+ if (response.data.choices[0].text !== undefined) {
156
+ result = util_1.Util.replaceArgumentsWithNumbers(args, response.data.choices[0].text);
157
+ result = result.replace(/^\n+|\n+$/g, '');
158
+ }
159
+ else {
160
+ console.error(`can not translate text with prompt :${prompt}`);
161
+ result = util_1.Util.replaceArgumentsWithNumbers(args, result);
162
+ }
163
+ return result;
164
+ });
165
+ }
166
+ }
167
+ exports.OpenAITranslate = OpenAITranslate;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auto-translate-json-library",
3
- "version": "1.1.5",
4
- "description": "Automatically translates JSON language files to other languages using Google Translate,AWS,Azure or DeepL",
3
+ "version": "1.2.0",
4
+ "description": "Automatically translates JSON language files to other languages using Google Translate,AWS,Azure,DeepL or OpenAI",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
7
7
  "scripts": {
@@ -9,7 +9,20 @@
9
9
  "build": "tsc",
10
10
  "start": "ts-node src/index.ts"
11
11
  },
12
- "keywords": [],
12
+ "keywords": [
13
+ "translate",
14
+ "language",
15
+ "json",
16
+ "flutter",
17
+ "angular",
18
+ "ngx-translate",
19
+ "transloco",
20
+ "auto-translate-json",
21
+ "google",
22
+ "Azure",
23
+ "DeepL",
24
+ "OpenAI"
25
+ ],
13
26
  "author": "codegrue",
14
27
  "repository": {
15
28
  "type": "git",
@@ -26,21 +39,22 @@
26
39
  }
27
40
  },
28
41
  "devDependencies": {
29
- "@types/node": "18.11.9",
30
- "@types/yargs": "17.0.13",
31
- "husky": "8.0.1",
32
- "prettier": "2.7.1",
42
+ "@types/node": "20.1.4",
43
+ "@types/yargs": "17.0.24",
44
+ "husky": "8.0.3",
45
+ "prettier": "2.8.8",
33
46
  "pretty-quick": "3.1.3",
34
47
  "ts-node": "10.9.1",
35
- "typescript": "4.8.4"
48
+ "typescript": "5.0.4"
36
49
  },
37
50
  "dependencies": {
38
- "@aws-sdk/client-translate": "3.199.0",
39
- "@google-cloud/translate": "6.3.1",
40
- "axios": "1.1.3",
51
+ "@aws-sdk/client-translate": "3.332.0",
52
+ "@google-cloud/translate": "7.2.1",
53
+ "axios": "1.4.0",
41
54
  "dotenv": "16.0.3",
42
55
  "form-data": "4.0.0",
56
+ "openai": "3.2.1",
43
57
  "uuid": "9.0.0",
44
- "yargs": "17.6.2"
58
+ "yargs": "17.7.2"
45
59
  }
46
60
  }
@@ -1,4 +1,4 @@
1
- export interface ITranslate {
2
- isValidLocale(targetLocale: string): boolean;
3
- translateText(text: string, sourceLocale: string, targetLocale: string): Promise<string>;
4
- }
1
+ export interface ITranslate {
2
+ isValidLocale(targetLocale: string): boolean;
3
+ translateText(text: string, sourceLocale: string, targetLocale: string): Promise<string>;
4
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/util.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export declare class Util {
2
- private static _startDelimiter;
3
- private static _endDelimiter;
4
- private static pattern;
5
- static set startDelimiter(value: string);
6
- static set endDelimiter(value: string);
7
- static replaceArgumentsWithNumbers(args: RegExpMatchArray | null, result: string): string;
8
- static replaceContextVariables(text: string): {
9
- args: RegExpMatchArray | null;
10
- text: string;
11
- };
12
- }
1
+ export declare class Util {
2
+ private static _startDelimiter;
3
+ private static _endDelimiter;
4
+ private static pattern;
5
+ static set startDelimiter(value: string);
6
+ static set endDelimiter(value: string);
7
+ static replaceArgumentsWithNumbers(args: RegExpMatchArray | null, result: string): string;
8
+ static replaceContextVariables(text: string): {
9
+ args: RegExpMatchArray | null;
10
+ text: string;
11
+ };
12
+ }