Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Latest commit

 

History

History
116 lines (93 loc) · 2.48 KB

File metadata and controls

116 lines (93 loc) · 2.48 KB

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

###[Up](#) Methods

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;
});

format(name : string, arguments : string[]) : string

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](#) Properties

L object has next public properties:

  • clanguage
  • clang
  • content_language
  • locale
  • _datetime_long
  • _datetime
  • _date
  • _time

Current language:

  • English
  • Russian
  • Ukrainian

clang

Short English lowercase variant of language name:

  • en
  • ru
  • uk

content_language

Short English lowercase variant of content language name (is used for Content-Language header):

  • en
  • ru
  • uk

locale

Locale:

  • en_US
  • ru_RU
  • uk_UA

_datetime_long

Long format of date and time for date() PHP function

_datetime

Short format of date and time for date() PHP function

_date

Short format of date for date() PHP function

_time

Short format of time for date() PHP function