mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
update docs
This commit is contained in:
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
collapsable: false,
|
collapsable: false,
|
||||||
children: [
|
children: [
|
||||||
['guide/accessibility', 'WAI-ARIA Spec'],
|
['guide/accessibility', 'WAI-ARIA Spec'],
|
||||||
['guide/localization', 'Localization / i18n'],
|
['guide/localization', 'Localization'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -342,6 +342,29 @@ label: {
|
|||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## locale <Badge text="v3.13.0+" />
|
||||||
|
|
||||||
|
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
|
## maxHeight
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# Localization / i18n
|
||||||
|
|
||||||
# Translations <Badge text="v3.13.0+" />
|
# Translations <Badge text="v3.13.0+" />
|
||||||
|
|
||||||
There are a number of strings used within the component that can all be translated. Out of the box,
|
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)
|
- [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)
|
- [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.
|
Translations can be set individually for each component instance, or globally for all instances in
|
||||||
Both methods will use the `locale` prop to determine the text to be used throughout the component.
|
your app. Both methods will use the `locale` prop to determine the text to be used throughout the
|
||||||
|
component.
|
||||||
|
|
||||||
**Locale Prop**
|
**Locale Prop**
|
||||||
|
|
||||||
@@ -25,6 +28,8 @@ the english locale that ships with Vue Select:
|
|||||||
|
|
||||||
<<< @/../src/locales/en.js
|
<<< @/../src/locales/en.js
|
||||||
|
|
||||||
|
[View this file on GitHub ](https://github.com/sagalbot/vue-select/tree/master/src/locales/en.js)
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { locale as english } from '../locales/en.js'
|
||||||
import ajax from '../mixins/ajax.js'
|
import ajax from '../mixins/ajax.js'
|
||||||
import i18n from '../mixins/i18n.js'
|
|
||||||
import pointerScroll from '../mixins/pointerScroll.js'
|
import pointerScroll from '../mixins/pointerScroll.js'
|
||||||
import typeAheadPointer from '../mixins/typeAheadPointer.js'
|
import typeAheadPointer from '../mixins/typeAheadPointer.js'
|
||||||
import childComponents from './childComponents'
|
import childComponents from './childComponents'
|
||||||
@@ -155,7 +155,7 @@ export default {
|
|||||||
|
|
||||||
directives: { appendToBody },
|
directives: { appendToBody },
|
||||||
|
|
||||||
mixins: [pointerScroll, typeAheadPointer, ajax, i18n],
|
mixins: [pointerScroll, typeAheadPointer, ajax],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
/**
|
/**
|
||||||
@@ -193,6 +193,23 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The locale function receives the default english translations for the
|
||||||
|
* component. This allows you to override the whole object, or change
|
||||||
|
* just the values you need.
|
||||||
|
*
|
||||||
|
* @since 3.13.0
|
||||||
|
* @see https://vue-select.org/guide/localization.html
|
||||||
|
*/
|
||||||
|
locale: {
|
||||||
|
type: Function,
|
||||||
|
/**
|
||||||
|
* @return {Object}
|
||||||
|
* @param localeStrings
|
||||||
|
*/
|
||||||
|
default: (localeStrings) => localeStrings,
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the entire component.
|
* Disable the entire component.
|
||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
@@ -660,6 +677,16 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
/**
|
||||||
|
* Return the strings that will be used throughout the
|
||||||
|
* component for labels, titles, text.
|
||||||
|
*
|
||||||
|
* @return {Object} locale
|
||||||
|
*/
|
||||||
|
i18n() {
|
||||||
|
return this.locale(english)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the component needs to
|
* Determine if the component needs to
|
||||||
* track the state of values internally.
|
* track the state of values internally.
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import { locale as english } from '../locales/en.js'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @this VueSelect
|
|
||||||
* @mixin
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
locale: {
|
|
||||||
type: Function,
|
|
||||||
/**
|
|
||||||
* @param text {Object}
|
|
||||||
* @return {Object}
|
|
||||||
*/
|
|
||||||
default: (text) => text,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
i18n() {
|
|
||||||
return this.locale(english)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user