-
Type:
String
-
Default:
en
-
Usage:
Get or set a translation language code. Default by
en
string value.Vue.config.lang = 'ja'
-
Type:
String
-
Default:
en
-
Usage:
Get or set a translation fallback language code. Default by
en
string value.Vue.config.fallbackLang = 'ja'
-
Type:
Function
-
Default:
null
-
Usage:
Assign a handler for translation missing. The handler gets called with the translation target language, translation key and the Vue instance.
If mssingHandler is assigned, and occured translation missing, it's not warned.
Vue.config.missingHandler = function (lang, key, vm) { // handle translation missing }
-
Type:
Function
-
Default:
null
-
Usage:
Assign a customer message formatter.
Vue.config.i18nFormatter = function (string, ...arguments) { //... //return formattedString; }
-
Arguments:
{String} lang
{Object | Function} [locale]
{Function} [cb]
-
Return:
- locale function or object
-
Usage:
Register or retrieve a locale
// register locale with object Vue.locale('en', { message: 'hello' }) // register with external locale Vue.locale('ja', function () { return fetch('/locales/ja', { method: 'get', // ... }).then(function (json) { return Promise.resolve(json) }).catch(function (error) { return Promise.reject() }) }, function () { Vue.config.lang = 'ja' })
-
Arguments:
{String} keypath
{String} [lang]
{Array | Object [arguments]
-
Return: Translated string
-
Usage: This is the same as the
$t
method. This is translate function for global locale only. more detail see $t.
-
Arguments:
{String} keypath
{Number} [choice] - default: 1
{String | Array | Object [arguments]
-
Return: Translated pluralization string
-
Usage: This is the same as the
$tc
method. This is translate pluralization function for global locale only. more detail see $tc.
-
Arguments:
{String} keypath
{String} [lang]
-
Return: Whether keypath exists, boolean value
-
Usage: Check whether key path exists in global locale. If you specified
lang
, check the locale oflang
.
-
Type:
Object
-
Details:
A locale definition object to be made available to the Vue instance only.
-
See also:
-
Arguments:
{String} keypath
{String} [lang]
{Array | Object [arguments]
-
Return: Translated string
-
Usage: Translate the locale of
keypath
. Translate in preferentially component locale than global locale. If not specified component locale, translate with global locale. If you specifiedlang
, translate the locale oflang
. If you specifiedkeypath
of list / named formatting local, you must specifyarguments
too. Forarguments
more details see Formatting.
-
Arguments:
{String} keypath
{Number} [choice] - default: 1
{String | Array | Object [arguments]
-
Return: Translated pluralization string
-
Usage:
Translate the locale of
keypath
with pluralization. Translate in preferentially component locale than global locale. If not specified component locale, translate with global locale. If you will specify String value toarguments
, translate the locale of value. If you wll specify Array or Object value toarguments
, you must specify witharguments
of $t.
-
Arguments:
{String} keypath
{String} [lang]
-
Return: Whether keypath exists, boolean value
-
Usage: Check whether key path exists. In Vue instance, If not specified component locale, check with global locale. If you specified
lang
, check the locale oflang
.
-
Return The lang you set via
Vue.config.lang
-
Usage You can do some complex things if you need. Note a good design should not rely on this too much.