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

fcf.appendTranslate() function

fcf.appendTranslate(object|string|[object|string]|undefined a_dataOrFileName, boolean a_reload = false)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Adds translations. If necessary, it can cause a complete reloading of all translation files.

Arguments

object|string|[object|string]|undefined a_dataOrFileName
- Path to a file with translation data or an object with a description of translations or an array containing objects and paths to files. Also the parameter can be set to undefined value, this can be used to completely reload all translation files.

Object format

If the argument is given by an object, then the object must contain two fields

  • string language - Translation language

  • object translations - Object with translations. The key is the string to be translated, and the value is the translation.

Example:

fcf.appendTranslate({ language: "ja", translations: { "Hello world": "こんにちは世界", } });

File path format with translations

Translations can be supplied from a JSON file. Then the argument must contain the path to the file in FCF notation.

The format of the translation file may be in the format of a translation object as described previously, or may be an array containing objects with information about translations.

:translations/translations.json file

{ language: "ja", translations: { "Hello world": "こんにちは世界", } }

Execution example:

fcf.appendTranslate(":translations/translations.json");

Array fromat

The argument can be passed as an array, the elements of which must either be objects describing translations, or be strings containing paths to files.

boolean a_reload
- If the argument is true, then a full reload of data from all files is performed, including those files that were loaded before the function call.