The above example uses the availableLocales property of VueI18n instance to list the available locales as options for the select element. If you want to change the locale for the whole application, global scope allows you to use the $i18n.locale for each component. So far, we’ve explained the concept of the scope, and once you understand the scope, it’s easy to understand how to change the locale. So, VueI18n instance of the component this.$i18n is not the same as VueI18n instance referenced with global property of the i18n instance. The local scope is enabled with specifying the i18n component option, which creates a VueI18n instance when the component is initialized. This is very useful if you want to manage the i18n resource like locale messages for each component. The local scope allows you to apply scopes on each component basis like the of single-file components, only that component’s scope is enabled. When global scope is enabled on a component, VueI18n instance accessed by this.$i18n is essentially the same as i18n instance global property. The global scope is enabled on the target component when the i18n component option is unspecified. What is global scoped is the one of the VueI18n instance that is accessible with global property of the i18n instance. The global scope is created when you create an i18n instance with createI18n, and the one to be scoped is the one for the VueI18n instance, which can be accessed by the i18n instance global property. The global scope is very useful if you want to centrally manage i18n resources across your application. The global scope allows you to refer to scopes in all components of the Vue application. To localize each of components in Vue I18n using the i18n features, we need to understand the concept of scope. The Vue application is built from some components on the tree structure. ![]() ![]() They are managed with the VueI18n instance. Vue I18n manages resources to offer i18n features, including locale switching, each language messages called locales messages, and named format for datetime and numbers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |