
As discussed in https://hackmd.io/33M5Wb-JT7-0fneA0JuHPA `SourceMessage` strings are not sufficient for matching translations. This commit updates `@angular/localize` to use `MessageId`s for translation matching instead. Also the run-time translation will now log a warning to the console if a translation is missing. BREAKING CHANGE: Translations (loaded via the `loadTranslations()` function) must now use `MessageId` for the translation key rather than the previous `SourceMessage` string. PR Close #32594
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* The character used to mark the start and end of a "block" in a `$localize` tagged string.
|
|
* A block can indicate metadata about the message or specify a name of a placeholder for a
|
|
* substitution expressions.
|
|
*
|
|
* For example:
|
|
*
|
|
* ```ts
|
|
* $localize`Hello, ${title}:title:!`;
|
|
* $localize`:meaning|description@@id:source message text`;
|
|
* ```
|
|
*/
|
|
export const BLOCK_MARKER = ':';
|
|
|
|
/**
|
|
* The marker used to separate a message's "meaning" from its "description" in a metadata block.
|
|
*
|
|
* For example:
|
|
*
|
|
* ```ts
|
|
* $localize `:correct|Indicates that the user got the answer correct: Right!`;
|
|
* $localize `:movement|Button label for moving to the right: Right!`;
|
|
* ```
|
|
*/
|
|
export const MEANING_SEPARATOR = '|';
|
|
|
|
/**
|
|
* The marker used to separate a message's custom "id" from its "description" in a metadata block.
|
|
*
|
|
* For example:
|
|
*
|
|
* ```ts
|
|
* $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;
|
|
* ```
|
|
*/
|
|
export const ID_SEPARATOR = '@@';
|