diff --git a/docs/.vuepress/config/themeConfig.js b/docs/.vuepress/config/themeConfig.js index edfb36a..456abcf 100644 --- a/docs/.vuepress/config/themeConfig.js +++ b/docs/.vuepress/config/themeConfig.js @@ -37,7 +37,7 @@ module.exports = { collapsable: false, children: [ ['guide/accessibility', 'WAI-ARIA Spec'], - ['guide/localization', 'Localization / i18n'], + ['guide/localization', 'Localization'], ], }, { diff --git a/docs/api/props.md b/docs/api/props.md index cfe3aca..2b2668a 100644 --- a/docs/api/props.md +++ b/docs/api/props.md @@ -342,6 +342,29 @@ label: { }, ``` +## locale + +The locale function receives the default english translations object for the component. This allows +you to override the whole object, or change just the values you need. Can be used to localize the +component to different languages, or just replace text to your liking throughout the component. + +See [localization guide](/guide/localization.html) for more details and examples. + +```js +/** + * @since 3.13.0 + * @see https://vue-select.org/guide/localization.html + */ +locale: { + type: Function, + /** + * @return {Object} + * @param localeStrings + */ + default: (localeStrings) => localeStrings, +}, +``` + ## maxHeight diff --git a/docs/guide/localization.md b/docs/guide/localization.md index c7f3a88..ff792af 100644 --- a/docs/guide/localization.md +++ b/docs/guide/localization.md @@ -1,3 +1,5 @@ +# Localization / i18n + # Translations There are a number of strings used within the component that can all be translated. Out of the box, @@ -8,8 +10,9 @@ in [`src/locales`](https://github.com/sagalbot/vue-select/tree/master/src/locale - [French](https://github.com/sagalbot/vue-select/tree/master/src/locales/fr.js) - [Spanish](https://github.com/sagalbot/vue-select/tree/master/src/locales/es.js) -Translations can be set on for each component instance, or globally for all instances in your app. -Both methods will use the `locale` prop to determine the text to be used throughout the component. +Translations can be set individually for each component instance, or globally for all instances in +your app. Both methods will use the `locale` prop to determine the text to be used throughout the +component. **Locale Prop** @@ -25,6 +28,8 @@ the english locale that ships with Vue Select: <<< @/../src/locales/en.js +[View this file on GitHub ](https://github.com/sagalbot/vue-select/tree/master/src/locales/en.js) + # Examples --- diff --git a/src/components/Select.vue b/src/components/Select.vue index 67bea76..00a547e 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -138,8 +138,8 @@