FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.translate() function

string|object fcf.translate(string|object a_str, string a_lang = fcf.getContext().language || fcf.getConfiguration().defaultLanguage)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Performs tokenization only for translation constructs !{{...}}! and !{...}!.


string|object a_str
- The string or object to be tokenized. If an object is passed, then all values stored in it and in nested objects that are strings are tokenized.

string a_lang = fcf.getContext().language || fcf.getConfiguration().defaultLanguage
- Translation language. If no translation is specified, then the language set in the execution context is used, or the default language if the language in the execution context is not specified.
- Returns a tokenized string or raw object, depending on the passed parameter a_str

Example: Function application

fcf.getConfiguration().append({ translations: [ { language: "ja", translations: { "Hello world": "こんにちは世界", } } ], }); fcf.getContext().language = "ja" let result = fcf.translate("Text: !{{Hello world}}!"); console.log(result);


Text: こんにちは世界