diff --git a/vuepress/.vuepress/public/patrons/sendcloud.svg b/vuepress/.vuepress/public/patrons/sendcloud.svg index 8be041559..fdde64b0d 100644 --- a/vuepress/.vuepress/public/patrons/sendcloud.svg +++ b/vuepress/.vuepress/public/patrons/sendcloud.svg @@ -1,50 +1,5 @@ - - - - - - - - - - - - - - - - - + + + + + diff --git a/vuepress/README.md b/vuepress/README.md index 4829ac9bd..890c1ba14 100644 --- a/vuepress/README.md +++ b/vuepress/README.md @@ -16,42 +16,42 @@ footer: MIT Licensed | Copyright © 2020 kazuya kawaguchi > Nuxt.js

🥈 Silver Sponsors

BabelEdit translation editor for apps (web apps)

🥉 Bronze Sponsors

zenarchitects sendcloud diff --git a/vuepress/api/README.md b/vuepress/api/README.md index a24e863d1..93074c784 100644 --- a/vuepress/api/README.md +++ b/vuepress/api/README.md @@ -25,6 +25,7 @@ Component based localization option. * `{Path} key`: required * `{Locale} locale`: optional * `{Array | Object} values`: optional + * **Return:** `TranslateResult` Localize the locale message of `key`. Localize in preferentially component locale messages than global locale messages. If not specified component locale messages, localize with global locale messages. If you specified `locale`, localize the locale messages of `locale`. If you specified `key` of list / named formatting local messages, you must specify `values` too. For `values` more details see [Formatting](../guide/formatting.md). @@ -43,6 +44,7 @@ Note that you need to guarantee this context equal to component instance in life * `{number} choice`: optional, default 1 * `{Locale} locale`: optional * `{string | Array | Object} values`: optional + * **Return:** `TranslateResult` Localize the locale message of `key` with pluralization. Localize in preferentially component locale messages than global locale messages. If not specified component locale messages, localize with global locale messages. If you specified `locale`, localize the locale messages of `locale`. If you will specify string value to `values`, localize the locale messages of value. If you will specify Array or Object value to `values`, you must specify with `values` of $t. @@ -57,6 +59,7 @@ Note that you need to guarantee this context equal to component instance in life * `{Path} key`: required * `{Locale} locale`: optional + * **Return:** `boolean` Check whether key exists. In Vue instance, If not specified component locale messages, check with global locale messages. If you specified `locale`, check the locale messages of `locale`. @@ -74,6 +77,7 @@ Note that you need to guarantee this context equal to component instance in life * `{number | Date} value`: required * `{Path | Object} key`: optional * `{Locale | Object} locale`: optional + * **Return:** `DateTimeFormatResult` Localize the datetime of `value` with datetime format of `key`. The datetime format of `key` need to register to `dateTimeFormats` option of `VueI18n` class, and depend on `locale` option of `VueI18n` constructor. If you will specify `locale` argument, it will have priority over `locale` option of `VueI18n` constructor. @@ -93,6 +97,7 @@ Note that you need to guarantee this context equal to component instance in life * `{number} value`: required * `{Path | Object} format`: optional * `{Locale} locale`: optional + * **Return:** `NumberFormatResult` Localize the number of `value` with number format of `format`. The number format of `format` need to register to `numberFormats` option of `VueI18n` class, and depend on `locale` option of `VueI18n` constructor. If you will specify `locale` argument, it will have priority over `locale` option of `VueI18n` constructor. @@ -315,6 +320,7 @@ If you use regular expression, you can suppress the fallback warnings that it ma { // Key - locale for the rule to be applied to. // Value - mapping function that maps a choice index from `$tc` to the actual choice of the plural word. (See getChoiceIndex for details) + 'pt': function(choice, choiceIndex) => Number/* index of the plural word */; 'ru': function(choice, choiceIndex) => Number/* index of the plural word */; 'en': function(choice, choiceIndex) => Number/* index of the plural word */; 'jp': function(choice, choiceIndex) => Number/* index of the plural word */; @@ -511,6 +517,7 @@ Whether to allow the use locale messages of HTML formatting. If you set `warn` or` error`, will check the locale messages on the VueI18n instance. If you are specified `warn`, a warning will be output at console. + If you are specified `error` will occurred an Error. In VueI18n instance, set the `off` as default. @@ -530,6 +537,7 @@ A handler for post processing of translation. #### getChoiceIndex * **Arguments:** + * `{number} choice` * `{number} choicesLength` @@ -549,6 +557,7 @@ However, for most usages [pluralizationRules constructor option](#pluralizationr * **Arguments:** * `{Locale} locale` + * **Return:** `LocaleMessageObject` Get the locale message of locale. @@ -592,6 +601,7 @@ If you set `warn` or` error` in the `warnHtmlInMessage` property, when this meth * `{Path} key`: required * `{Locale} locale`: optional * `{Array | Object} values`: optional + * **Return:** : `TranslateResult` This is the same as the `Function` returned with `$t` method. More detail see [$t](#t). @@ -603,6 +613,7 @@ This is the same as the `Function` returned with `$t` method. More detail see [$ * `{Path} key`: required * `{number} choice`: optional, default `1` * `{string | Array | Object} values`: optional + * **Return:** `TranslateResult` This is the same as the `Function` returned `$tc` method. More detail see [$tc](#tc). @@ -613,6 +624,7 @@ This is the same as the `Function` returned `$tc` method. More detail see [$tc]( * `{string} key`: required * `{Locale} locale`: optional + * **Return:** `boolean` Check whether key path exists in global locale message. If you specified `locale`, check the locale message of `locale`. @@ -624,6 +636,7 @@ Check whether key path exists in global locale message. If you specified `locale * **Arguments:** * `{Locale} locale` + * **Return:** `DateTimeFormat` Get the datetime format of locale. @@ -659,6 +672,7 @@ Merge the registered datetime formats with the datetime format of locale. * `{number | Date} value`: required * `{Path | Object} key`: optional * `{Locale | Object} locale`: optional + * **Return:** `DateTimeFormatResult` This is the same as `$d` method of Vue instance method. More detail see [$d](#d). @@ -670,6 +684,7 @@ This is the same as `$d` method of Vue instance method. More detail see [$d](#d) * **Arguments:** * `{Locale} locale` + * **Return:** `NumberFormat` Get the number format of locale. @@ -705,6 +720,7 @@ Merge the registered number formats with the number format of locale. * `{number} value`: required * `{Path | Object} format`: optional * `{Locale} locale`: optional + * **Return:** `NumberFormatResult` This is the same as `$n` method of Vue instance method. More detail see [$n](#n). @@ -725,14 +741,16 @@ This is the same as `$n` method of Vue instance method. More detail see [$n](#n) Update the element `textContent` that localized with locale messages. You can use string syntax or object syntax. string syntax can be specified as a keypath of locale messages. If you can be used object syntax, you need to specify as the object key the following params: - * path: required, key of locale messages - * locale: optional, locale - * args: optional, for list or named formatting + * `path`: required, key of locale messages + * `locale`: optional, locale + * `args`: optional, for list or named formatting :::tip NOTE The element `textContent` will be cleared by default when `v-t` directive is unbinded. This might be undesirable situation when used inside [transitions](https://vuejs.org/v2/guide/transitions.html). To preserve `textContent` data after directive unbind use `.preserve` modifier or global [`preserveDirectiveContent` option](#preservedirectivecontent). ::: + * **Examples:** + ```html

diff --git a/vuepress/guide/component.md b/vuepress/guide/component.md index 256c74c4b..ec0d7926f 100644 --- a/vuepress/guide/component.md +++ b/vuepress/guide/component.md @@ -92,6 +92,7 @@ Sometimes you may want to import shared locale messages for certain components, You can use `sharedMessages` options of `i18n`. Common Locale Messages example: + ```js export default { en: { @@ -121,7 +122,9 @@ export default {

This is good service

`, @@ -137,16 +140,13 @@ If `sharedMessages` option is specified along with the `messages` option, those ## Translation in functional component -When using a functional component, all data (including props, children, slots, parent, etc.) is passed through the `context` containing the attributes, and it doesn't recognize the `this` scope, so when using the vue-i18n on functional components, you must refer to `$t` as `parent.$t`, check the example below: +When using a functional component, all data (including `props`, `children`, `slots`, `parent`, etc.) is passed through the `context` containing the attributes, and it doesn't recognize the `this` scope, so when using the vue-i18n on functional components, you must refer to `$t` as `parent.$t`, check the example below: ```html ...
- - + +
... diff --git a/vuepress/guide/datetime.md b/vuepress/guide/datetime.md index 233816926..77a51099c 100644 --- a/vuepress/guide/datetime.md +++ b/vuepress/guide/datetime.md @@ -12,20 +12,33 @@ DateTime formats the below: const dateTimeFormats = { 'en-US': { short: { - year: 'numeric', month: 'short', day: 'numeric' + year: 'numeric', + month: 'short', + day: 'numeric' }, long: { - year: 'numeric', month: 'short', day: 'numeric', - weekday: 'short', hour: 'numeric', minute: 'numeric' + year: 'numeric', + month: 'long', + day: 'numeric', + weekday: 'long', + hour: 'numeric', + minute: 'numeric' } }, 'ja-JP': { short: { - year: 'numeric', month: 'short', day: 'numeric' + year: 'numeric', + month: 'short', + day: 'numeric' }, long: { - year: 'numeric', month: 'short', day: 'numeric', - weekday: 'short', hour: 'numeric', minute: 'numeric', hour12: true + year: 'numeric', + month: 'long', + day: 'numeric', + weekday: 'long', + hour: 'numeric', + minute: 'numeric', + hour12: true } } } @@ -58,7 +71,7 @@ Output the below: ```html
-

Apr 19, 2017

-

2017年4月19日(水) 午前2:19

+

Jan 18, 2021

+

2021年1月18日日曜日 午前5:47

``` diff --git a/vuepress/guide/fallback.md b/vuepress/guide/fallback.md index f46c29e9e..549cdb21c 100644 --- a/vuepress/guide/fallback.md +++ b/vuepress/guide/fallback.md @@ -23,6 +23,7 @@ const messages = { hello: 'Hello, world!' }, ja: { + // Localization without translation to `hello` } } ``` diff --git a/vuepress/guide/interpolation.md b/vuepress/guide/interpolation.md index fdbf0727f..44ad212fb 100644 --- a/vuepress/guide/interpolation.md +++ b/vuepress/guide/interpolation.md @@ -87,7 +87,9 @@ the following output: About the above example, see the [example](https://github.com/kazupon/vue-i18n/tree/dev/examples/interpolation/places) -The children of `i18n` functional component are interpolated with locale message of `path` prop. In the above example, +The children of `i18n` functional component are interpolated with locale message of `path` prop. + +In the above example: :::v-pre `{{ $t('tos') }}` ::: diff --git a/vuepress/guide/locale.md b/vuepress/guide/locale.md index bfbb17c7a..a9f9ebb07 100644 --- a/vuepress/guide/locale.md +++ b/vuepress/guide/locale.md @@ -25,11 +25,13 @@ Each component contains a `VueI18n` instance referenced as the `$i18n` property Example: -```html +```vue diff --git a/vuepress/guide/messages.md b/vuepress/guide/messages.md index b65bab67f..3be84c052 100644 --- a/vuepress/guide/messages.md +++ b/vuepress/guide/messages.md @@ -151,16 +151,16 @@ You can add modifiers or overwrite the existing ones passing the `modifiers` opt ```javascript const i18n = new VueI18n({ locale: 'en', + modifiers: { + // Adding a new modifier + snakeCase: (str) => str.split(' ').join('-') + }, messages: { // ... }, - modifiers: { - snakeCase: (str) => str.split(' ').join('-') - } }) ``` - ### Grouping by brackets A translation key of linked locale message can also have the form of `@:(message.foo.bar.baz)` in which the link to another translation key is within brackets `()`. diff --git a/vuepress/guide/number.md b/vuepress/guide/number.md index 3a4331fb6..630d5fff8 100644 --- a/vuepress/guide/number.md +++ b/vuepress/guide/number.md @@ -12,12 +12,15 @@ Number formats the below: const numberFormats = { 'en-US': { currency: { - style: 'currency', currency: 'USD' + style: 'currency', + currency: 'USD' } }, 'ja-JP': { currency: { - style: 'currency', currency: 'JPY', currencyDisplay: 'symbol' + style: 'currency', + currency: 'JPY', + currencyDisplay: 'symbol' } } } @@ -121,7 +124,6 @@ It is possible to specify multiple scoped slots at the same time: 1 , 234 - . 00 ``` diff --git a/vuepress/guide/pluralization.md b/vuepress/guide/pluralization.md index f53fbe2fa..3e32bc656 100644 --- a/vuepress/guide/pluralization.md +++ b/vuepress/guide/pluralization.md @@ -131,7 +131,7 @@ const messages = { } ``` Where the format is `0 things | things count ends with 1 | things count ends with 2-4 | things count ends with 5-9, 0 and teens (10-19)`. -P.S. Slavic pluralization is a pain, you can read more about it [here](http://www.russianlessons.net/lessons/lesson11_main.php). +P.S. Slavic pluralization is difficult, you can read more about it [here](http://www.russianlessons.net/lessons/lesson11_main.php). Your template still needs to use `$tc()`, not `$t()`: diff --git a/vuepress/guide/sfc.md b/vuepress/guide/sfc.md index e5c348d1d..0220e274c 100644 --- a/vuepress/guide/sfc.md +++ b/vuepress/guide/sfc.md @@ -6,7 +6,7 @@ If you are building Vue component or Vue application using single file component The following in [single file components example](https://github.com/kazupon/vue-i18n/tree/dev/examples/sfc): -```js +```vue { "en": { @@ -200,7 +200,7 @@ mix.i18n() the `i18n` custom blocks below of `YAML` format: -```html +```vue en: hello: "hello world!" @@ -260,7 +260,7 @@ module.exports = { You can use locale messages with multiple `i18n` custom blocks. -```html +```vue { @@ -284,8 +284,7 @@ When using `vue-i18n` with `scoped style`, it's important to remember to use a [ __Translation contains only text__ (Work without deep selector) -```html -... +```vue { "en": { @@ -296,24 +295,24 @@ __Translation contains only text__ (Work without deep selector) } } -... + -... + - ``` __Translation with HTML element__ (Must use deep selector) -```html -... + +```vue { "en": { @@ -324,37 +323,57 @@ __Translation with HTML element__ (Must use deep selector) } } -... + -... + - - - -``` + + + + + +``` ## Custom blocks in functional component @@ -362,7 +381,7 @@ If the single file components have the template using a functional component, an For example, the following code cannot localize with the locale message of `i18n` custom block. -```html +```vue { "en": { diff --git a/vuepress/installation.md b/vuepress/installation.md index 0f0d80887..abd0d3a7e 100644 --- a/vuepress/installation.md +++ b/vuepress/installation.md @@ -12,20 +12,20 @@ Include vue-i18n after Vue and it will install itself automatically: - -```html + +```html ``` ## NPM - + ```sh npm install vue-i18n -``` +``` ## Yarn - + ```sh yarn add vue-i18n ``` @@ -33,7 +33,7 @@ yarn add vue-i18n When using with a module system, you must explicitly install the `vue-i18n` via `Vue.use()`: - + ```javascript import Vue from 'vue' import VueI18n from 'vue-i18n' @@ -41,10 +41,10 @@ import VueI18n from 'vue-i18n' Vue.use(VueI18n) ``` -You don't need to do this when using global script tags. +You don't need to do this when using global script tags `