添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
伤情的脸盆  ·  tclsh8.6 linux ...·  1 月前    · 
坏坏的猕猴桃  ·  setTimeout和setInterval ...·  2 年前    · 
健身的冲锋衣  ·  Feign ErrorDecoder : ...·  2 年前    · 
Skip to content
i18next-vue

Composition API

You can access both the translation function t as well as the i18next instance used by i18next-vue using the composition API.

Make sure to set up i18next-vue for your app beforehand.

Even without calling useTranslation() you can use $t and $i18next in your <template> part.

Customize t Since 3.0

useTranslation() can be used to get a custom t function with a specific namespace, language and/or key prefix:

useTranslation() supports passing in a single name space or an array of namespaces to use. These namespaces will be loaded, if they are not available yet.

As a second argument, you can pass an object setting the keyPrefix (i.e. a prefix to put before all translation keys passed to this t ) and/or a fixed translation language using lng .

Both this special t and the default $t (unaffected by the options) can be used alongside each other in the template.

You can call useTranslation multiple times, to e.g. create multiple translation functions for different namespaces.

TIP

If you use certain namespaces/key prefixes a lot, it might make sense to extract composition functions for those to a separate JS module and use these in your components.