Skip to content

Commit 99a27e7

Browse files
committed
Revert "[i18n] integrate new translations + new i18n check elastic#70193 (elastic#70423)"
This reverts commit 2212beb.
1 parent f5b77e1 commit 99a27e7

File tree

8 files changed

+3477
-510
lines changed

8 files changed

+3477
-510
lines changed

src/dev/i18n/integrate_locale_files.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { mockMakeDirAsync, mockWriteFileAsync } from './integrate_locale_files.t
2121

2222
import path from 'path';
2323
import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files';
24-
// @ts-expect-error
24+
// @ts-ignore
2525
import { normalizePath } from './utils';
2626

2727
const localePath = path.resolve(__dirname, '__fixtures__', 'integrate_locale_files', 'fr.json');
@@ -36,7 +36,6 @@ const defaultIntegrateOptions = {
3636
sourceFileName: localePath,
3737
dryRun: false,
3838
ignoreIncompatible: false,
39-
ignoreMalformed: false,
4039
ignoreMissing: false,
4140
ignoreUnused: false,
4241
config: {

src/dev/i18n/integrate_locale_files.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import {
3131
normalizePath,
3232
readFileAsync,
3333
writeFileAsync,
34-
verifyICUMessage,
35-
// @ts-expect-error
34+
// @ts-ignore
3635
} from './utils';
3736

3837
import { I18nConfig } from './config';
@@ -42,7 +41,6 @@ export interface IntegrateOptions {
4241
sourceFileName: string;
4342
targetFileName?: string;
4443
dryRun: boolean;
45-
ignoreMalformed: boolean;
4644
ignoreIncompatible: boolean;
4745
ignoreUnused: boolean;
4846
ignoreMissing: boolean;
@@ -107,23 +105,6 @@ export function verifyMessages(
107105
}
108106
}
109107

110-
for (const messageId of localizedMessagesIds) {
111-
const defaultMessage = defaultMessagesMap.get(messageId);
112-
if (defaultMessage) {
113-
try {
114-
const message = localizedMessagesMap.get(messageId)!;
115-
verifyICUMessage(message);
116-
} catch (err) {
117-
if (options.ignoreMalformed) {
118-
localizedMessagesMap.delete(messageId);
119-
options.log.warning(`Malformed translation ignored (${messageId}): ${err}`);
120-
} else {
121-
errorMessage += `\nMalformed translation (${messageId}): ${err}\n`;
122-
}
123-
}
124-
}
125-
}
126-
127108
if (errorMessage) {
128109
throw createFailError(errorMessage);
129110
}

src/dev/i18n/tasks/check_compatibility.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ import { integrateLocaleFiles, I18nConfig } from '..';
2222

2323
export interface I18nFlags {
2424
fix: boolean;
25-
ignoreMalformed: boolean;
2625
ignoreIncompatible: boolean;
2726
ignoreUnused: boolean;
2827
ignoreMissing: boolean;
2928
}
3029

3130
export function checkCompatibility(config: I18nConfig, flags: I18nFlags, log: ToolingLog) {
32-
const { fix, ignoreIncompatible, ignoreUnused, ignoreMalformed, ignoreMissing } = flags;
31+
const { fix, ignoreIncompatible, ignoreUnused, ignoreMissing } = flags;
3332
return config.translations.map((translationsPath) => ({
3433
task: async ({ messages }: { messages: Map<string, { message: string }> }) => {
3534
// If `fix` is set we should try apply all possible fixes and override translations file.
@@ -38,7 +37,6 @@ export function checkCompatibility(config: I18nConfig, flags: I18nFlags, log: To
3837
ignoreIncompatible: fix || ignoreIncompatible,
3938
ignoreUnused: fix || ignoreUnused,
4039
ignoreMissing: fix || ignoreMissing,
41-
ignoreMalformed: fix || ignoreMalformed,
4240
sourceFileName: translationsPath,
4341
targetFileName: fix ? translationsPath : undefined,
4442
config,

src/dev/i18n/utils.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,6 @@ export function checkValuesProperty(prefixedValuesKeys, defaultMessage, messageI
208208
}
209209
}
210210

211-
/**
212-
* Verifies valid ICU message.
213-
* @param message ICU message.
214-
* @param messageId ICU message id
215-
* @returns {undefined}
216-
*/
217-
export function verifyICUMessage(message) {
218-
try {
219-
parser.parse(message);
220-
} catch (error) {
221-
if (error.name === 'SyntaxError') {
222-
const errorWithContext = createParserErrorMessage(message, {
223-
loc: {
224-
line: error.location.start.line,
225-
column: error.location.start.column - 1,
226-
},
227-
message: error.message,
228-
});
229-
throw errorWithContext;
230-
}
231-
}
232-
}
233211
/**
234212
* Extracts value references from the ICU message.
235213
* @param message ICU message.

src/dev/run_i18n_check.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ run(
3636
async ({
3737
flags: {
3838
'ignore-incompatible': ignoreIncompatible,
39-
'ignore-malformed': ignoreMalformed,
4039
'ignore-missing': ignoreMissing,
4140
'ignore-unused': ignoreUnused,
4241
'include-config': includeConfig,
@@ -49,13 +48,12 @@ run(
4948
fix &&
5049
(ignoreIncompatible !== undefined ||
5150
ignoreUnused !== undefined ||
52-
ignoreMalformed !== undefined ||
5351
ignoreMissing !== undefined)
5452
) {
5553
throw createFailError(
5654
`${chalk.white.bgRed(
5755
' I18N ERROR '
58-
)} none of the --ignore-incompatible, --ignore-malformed, --ignore-unused or --ignore-missing is allowed when --fix is set.`
56+
)} none of the --ignore-incompatible, --ignore-unused or --ignore-missing is allowed when --fix is set.`
5957
);
6058
}
6159

@@ -101,7 +99,6 @@ run(
10199
checkCompatibility(
102100
config,
103101
{
104-
ignoreMalformed: !!ignoreMalformed,
105102
ignoreIncompatible: !!ignoreIncompatible,
106103
ignoreUnused: !!ignoreUnused,
107104
ignoreMissing: !!ignoreMissing,

src/dev/run_i18n_integrate.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ run(
3131
'ignore-incompatible': ignoreIncompatible = false,
3232
'ignore-missing': ignoreMissing = false,
3333
'ignore-unused': ignoreUnused = false,
34-
'ignore-malformed': ignoreMalformed = false,
3534
'include-config': includeConfig,
3635
path,
3736
source,
@@ -67,13 +66,12 @@ run(
6766
typeof ignoreIncompatible !== 'boolean' ||
6867
typeof ignoreUnused !== 'boolean' ||
6968
typeof ignoreMissing !== 'boolean' ||
70-
typeof ignoreMalformed !== 'boolean' ||
7169
typeof dryRun !== 'boolean'
7270
) {
7371
throw createFailError(
7472
`${chalk.white.bgRed(
7573
' I18N ERROR '
76-
)} --ignore-incompatible, --ignore-unused, --ignore-malformed, --ignore-missing, and --dry-run can't have values`
74+
)} --ignore-incompatible, --ignore-unused, --ignore-missing, and --dry-run can't have values`
7775
);
7876
}
7977

@@ -99,7 +97,6 @@ run(
9997
ignoreIncompatible,
10098
ignoreUnused,
10199
ignoreMissing,
102-
ignoreMalformed,
103100
config,
104101
log,
105102
});

0 commit comments

Comments
 (0)