Lzh on GitHub

Vue I18n

Vue I18n 的扩展

title: Vue I18n description: Vue I18n 的扩展

Composer(用于组合式 API)VueI18n(用于旧版 API) 实例作为 $i18n 暴露在 Vue 实例上。

getLocaleCookie()

  • 参数
    • 无参数
  • 返回string | undefined

从存储的语言环境 cookie 中返回语言环境代码。

setLocaleCookie()

  • 参数
    • 语言环境(类型:string
  • 返回undefined

使用指定的语言环境代码更新存储的语言环境 cookie。如果您想切换语言环境,请考虑使用 setLocale

setLocale()

  • 参数
    • 语言环境(类型:string
  • 返回Promise<void>

将应用程序的语言环境切换到指定的语言环境代码。如果启用 useCookie 选项,语言环境 cookie 将使用新值更新。如果启用前缀(strategy 不是 no_prefix),将导航到新语言环境的路由。

loadLocaleMessages()

  • 参数
    • 语言环境(类型:string
  • 返回Promise<void>

加载指定语言环境代码的翻译消息,这与使用非已加载语言环境的翻译相关。

getBrowserLocale()

  • 参数
    • 无参数
  • 返回string | undefined

返回根据选项中定义的浏览器语言环境代码筛选后的语言环境代码。

finalizePendingLocaleChange()

  • 参数
    • 无参数
  • 返回Promise<void>

将语言环境切换到待定语言环境,当导航语言环境切换被 skipSettingLocaleOnNavigate 选项阻止时使用。有关更多信息,请参阅 等待页面过渡

waitForPendingLocaleChange()

  • 参数
    • 无参数
  • 返回Promise<void>

返回一个 Promise,该 Promise 将在待定语言环境设置后解析。

strategy

  • 类型:Strategies

选项中指定的路由策略。

defaultDirection

  • 类型Directions

选项中指定的默认方向。

defaultLocale

  • 类型string

选项中指定的默认语言环境。

localeCodes

  • 类型Array<string>

已注册语言环境的语言环境代码列表。

locales

  • 类型Array<string | LocaleObject>

选项中定义的语言环境列表。

localeProperties

  • 类型LocaleObject

当前语言环境属性的对象。

differentDomains

  • 类型boolean

differentDomains 选项是否启用。