Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 757 Bytes

translate.md

File metadata and controls

37 lines (27 loc) · 757 Bytes

.translate( path )

Translate item given its path.

For translation inheritance, see the Example section of .loadTranslations().

Parameters

path

String or Array containing the translation item path, eg. "greetings/bye", or [ "greetings", "bye" ].

Example

You can use the static method Globalize.translate(), which uses the default locale.

Globalize.loadTranslations({
  greetings: {
    bye: "Tchau"
  }
});

Globalize.locale( "pt-BR" );
Globalize.translate( "greetings/bye" );
// ➡ "Tchau"

You can use the instance method .translate(), which uses the instance locale.

var ptBr = new Globalize( "pt-BR" );
ptBr.translate( "greetings/bye" );
// ➡ "Tchau"