Copyright © 2021 by K4.org
  (v.0.48.124)

Defines the language translation table. The table needs to be provided as an SQLite DB. Although the author can create tables with any column names, we recommend using international standard locale ids, such as 'en-us' and 'jp-jp'.

Index

Rules

columnNames

columnNames: Array

A list of all of the column names in the translation table.

Flags : Cached (Note this is uncached)

Expression : const sql = SELECT name FROM PRAGMA_TABLE_INFO('translation'); return this.getArray(sql).map(item => item.name);

keyLanguage

keyLanguage: String

The source language used to identify the key column in the translations table. The str argument to translate() must appear in this column.

Flags : Cached, Parameter (Note this is uncached)

Expression : "en-us"

readOnly

readOnly: Boolean

Locked to read-only.

Flags : Cached (Note this is uncached)

Expression : true

targetLanguage

targetLanguage: String

The language to be used as the target, if not specified in the translate() call. This must match a column name in the translations table.

Flags : Cached, Parameter (Note this is uncached)

Expression : "en-us"

translate

translate: Any

translate(str, lang) Looks up str in the key column and returns the corresponding string in the lang column. If lang is not provided, uses the current targetLanguage value.

Flags : Method (Note this is uncached)

Expression : return function(str, lang) { const target = lang ? lang : this.targetLanguage; const sql = SELECT * FROM translation WHERE [${this.keyLanguage}]='${str}'; let res; try { res = this.getValue(sql, target); } catch (e) { res = ${str}; R.message.warn(Unable to translate '${str}'); } return res; };