L
- is system object, that provides multilingual interface functionality, instance can be obtained in such way:
window.cs.Language.ready().then(function (L) {
// Use L here
});
Also there is possibility to simplify getting translations with common prefix:
window.cs.Language(prefix).ready().then(function (L) {
// Use L here
});
In case of prefixed usage full keys are still available, but prefixed keys are preferred in case of conflict.
Object is similar to $L object on backend, but have less number of methods.
L
is used only because it is short for frequent usage
L
object has next public methods:
- get()
- format()
Get translation.
cs.Language.ready().then(function (L) {
L.get('module_name');
});
Also there is simplified way to get translation - to get it as property of object:
cs.Language.ready().then(function (L) {
L.module_name;
});
Method is used for formatted translation. Example:
translation (in json file)
"hello":"Hello, %s!"
usage
cs.Language.ready().then(function (L) {
L.format('hello', ['my friend']);
});
Translation string should be formatted according to sprintf() PHP function.
Also there is simplified way to get formatted string - to get it as result of calling of object function:
cs.Language.ready().then(function (L) {
L.hello('my friend')
});
This way is more natural. You can specify as much arguments as you need.
###[Up](#) PropertiesL
object has next public properties:
- clanguage
- clang
- content_language
- locale
- _datetime_long
- _datetime
- _date
- _time
Current language:
- English
- Russian
- Ukrainian
Short English lowercase variant of language name:
- en
- ru
- uk
Short English lowercase variant of content language name (is used for Content-Language header):
- en
- ru
- uk
Locale:
- en_US
- ru_RU
- uk_UA
Long format of date and time for date()
PHP function
Short format of date and time for date()
PHP function
Short format of date for date()
PHP function
Short format of time for date()
PHP function