fix(localize): include legacy ids when describing messages (#36761)

Previously, we only displayed the new `$localize` id, which is not
currently what most people have in their translation files.
Until people migrate to the new message id system it is confusing
not to display the legacy ids.

PR Close #36761
This commit is contained in:
Pete Bacon Darwin 2020-04-22 15:28:04 +01:00 committed by Matias Niemelä
parent 781f5611d1
commit 47f98673c7
2 changed files with 10 additions and 1 deletions

View File

@ -123,5 +123,7 @@ export function makeTemplateObject(cooked: string[], raw: string[]): TemplateStr
function describeMessage(message: ParsedMessage): string {
const meaningString = message.meaning && ` - "${message.meaning}"`;
return `"${message.messageId}" ("${message.messageString}"${meaningString})`;
const legacy =
message.legacyIds.length > 0 ? ` [${message.legacyIds.map(l => `"${l}"`).join(', ')}]` : '';
return `"${message.messageId}"${legacy} ("${message.messageString}"${meaningString})`;
}

View File

@ -82,6 +82,13 @@ describe('utils', () => {
it('should throw an error if there is no matching translation', () => {
expect(() => doTranslate({}, parts`abc`))
.toThrowError('No translation found for "2674653928643152084" ("abc").');
expect(() => doTranslate({}, parts`:@@customId:abc`))
.toThrowError('No translation found for "customId" ("abc").');
expect(
() => doTranslate(
{}, parts`:␟d42e3c2d3aa340581d42f53c46eb49ecb3d3beb4␟3896949568605777881:abc`))
.toThrowError(
'No translation found for "2674653928643152084" ["d42e3c2d3aa340581d42f53c46eb49ecb3d3beb4", "3896949568605777881"] ("abc").');
expect(() => doTranslate({}, parts`:meaning|:abc`))
.toThrowError('No translation found for "1071947593002928768" ("abc" - "meaning").');
});