Singleton

Version 0.6

One-fits-all Internationalization Solution

Translate Pipe

Overview

Use the translate pipe in your HTML templates to retrieve translations from the singleton service.

API

L10n pipe

Get translation by key, will find the source in the sourceBundle according to the key.

{{ key | vtranslate:[ : variables ] }}

Input

Parameter Type Required
Description
key string required Define the key to identify the translation, it should name like this: component_module_page_control_shortmsg. e.g. web_settings_stats_statsTable_host;
variables Array[] optional Parameter array, it’s used to format the translation/source when they contain placeholders.

Example Code

export const ENGLISH = {
    'some.unique.key' : 'English for some.unique.key',
    'singleton.description' : '{0} is common lib developed by VMware G11n team.',
    'innerHTML.usage' : 'For more details, please refer to [Singleton Angular Client](https://github.com/vmware/singleton/tree/g11n-angular-client).'
    // innerHTML usage: use the innerHTML attribute with the pipe on any element. Not only for plain text node, also for raw HTML tags in source strings as inline tags.
    // Note: Convert " to " for the value of attribute.
}
// L10n pipe
{{'some.unique.key' | vtranslate }}

{{'singleton.description' | vtranslate: 'Singleton for Angular client'}}

// L10n pipe innerHTML sample
<label [innerHTML]="'innerHTML.usage' | vtranslate"></label>
Last updated on 24 Sep 2019
Published on 24 Sep 2019
 Edit on GitHub