Thanks to the Otter VSCode extension, you can extract a localization key from selected text in a component's template. The name and the description of this localization key will be set by the user when asked by the prompt. This key will be added to the localization file of the component and will replace the text in the template.
Otter: Add localization key to component
The HTML template contains text that needs to be translated.
Example :<!-- template file -->
<div>
<label>This is some sample text.</label>
</div>
In order to create a localization key and its description in the localization file of the component:
Otter: Add localization key to component
<!-- template file -->
<div>
<label>{{ translations.sampleText | o3rTranslate }}</label>
</div>
// localization file
{
"o3r-sample-component.sampleText": {
"defaultValue": "This is some sample text.",
"description": "Description of the sample text."
}
}