primevue-mirror/apps/showcase/doc/configuration/locale/SetLocaleDoc.vue

52 lines
1.3 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Second parameter of the use function can be used to initiate the locale during PrimeVue installation.</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code1" hideToggleCode importCode hideStackBlitz />
2023-02-28 08:29:30 +00:00
<p>The locale configuration is reactive so that any changes are instantly reflected in the UI. Suppose you are doing a multi language application and need to change the language dynamically.</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code2" hideToggleCode importCode hideStackBlitz />
2023-02-28 08:29:30 +00:00
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
2023-09-22 12:54:14 +00:00
basic: `
app.use(PrimeVue, {
2023-02-28 08:29:30 +00:00
locale: {
accept: 'Aceptar',
reject: 'Rechazar',
//...
}
2023-09-22 12:54:14 +00:00
});
`
2023-02-28 08:29:30 +00:00
},
code2: {
2023-09-22 12:54:14 +00:00
basic: `
import { defineComponent, onMounted } from "vue";
2023-02-28 08:29:30 +00:00
import { usePrimeVue } from "primevue/config";
export default defineComponent({
setup() {
const changeToSpanish = () => {
const primevue = usePrimeVue();
primevue.config.locale.accept = "Aceptar";
primevue.config.locale.reject = "Rechazar";
}
onMounted(() => {
changeToSpanish();
})
}
2023-09-22 12:54:14 +00:00
});
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>