Skip to content

Commit

Permalink
pr
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Oct 4, 2023
1 parent a609bb8 commit 81b2330
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions core/lib/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ function createIcuMessageFn(filename, fileStrings) {
const unixStyleFilename = filenameToLookup.replace(/\\/g, '/');
const i18nId = `${unixStyleFilename} | ${keyname}`;

message = escapeIcuMessage(message);

return {
i18nId,
values,
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/i18n/collect-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function parseExampleJsDoc(rawExample) {
* @return {IncrementalCtc}
*/
function convertMessageToCtc(lhlMessage, examples = {}) {
_lhlValidityChecks(escapeIcuMessage(lhlMessage));
_lhlValidityChecks(lhlMessage);

/** @type {IncrementalCtc} */
const ctc = {
Expand Down Expand Up @@ -192,7 +192,7 @@ function convertMessageToCtc(lhlMessage, examples = {}) {
function _lhlValidityChecks(lhlMessage) {
let parsedMessageElements;
try {
parsedMessageElements = MessageParser.parse(lhlMessage, {ignoreTag: true});
parsedMessageElements = MessageParser.parse(escapeIcuMessage(lhlMessage), {ignoreTag: true});
} catch (err) {
if (err.name !== 'SyntaxError') throw err;
throw new Error(`[${err.message}] Did not find the expected syntax in message: ${err.originalMessage}`);
Expand Down
6 changes: 4 additions & 2 deletions shared/localization/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {getModuleDirectory} from '../esm-utils.js';
import {isObjectOfUnknownValues, isObjectOrArrayOfUnknownValues} from '../type-verifiers.js';
import {locales} from './locales.js';

// From @formatjs/icu-messageformat-parser
// From @formatjs/icu-messageformat-parser - copy here so we don't need to bundle all that.
const TYPE = /** @type {const} */ ({
literal: 0,
argument: 1,
Expand Down Expand Up @@ -196,6 +196,8 @@ function escapeIcuMessage(message) {
* @return {string}
*/
function formatMessage(message, values, locale) {
message = escapeIcuMessage(message);

// Parsing and formatting can be slow. Don't attempt if the string can't
// contain ICU placeholders, in which case formatting is already complete.

Expand Down Expand Up @@ -243,7 +245,7 @@ function _localizeIcuMessage(icuMessage, locale) {
return icuMessage.formattedDefault;
}

return formatMessage(escapeIcuMessage(localeMessage.message), icuMessage.values, locale);
return formatMessage(localeMessage.message, icuMessage.values, locale);
}

/**
Expand Down

0 comments on commit 81b2330

Please sign in to comment.