Api

Vue I18n

Vue I18n 的扩展
Composer(用于组合 API)VueI18n(用于旧版 API) 的实例在 Vue 实例中暴露为 $i18n

getLocaleCookie()

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

从存储的区域设置 cookie 中返回区域设置代码。

setLocaleCookie()

  • 参数
    • locale(类型:string
  • 返回undefined

用指定的区域设置代码更新存储的区域设置 cookie。如果您想切换区域设置,请考虑使用 setLocale

setLocale()

  • 参数
    • locale(类型:string
  • 返回Promise<void>

将应用程序的区域设置切换到指定的区域设置代码。如果启用了 useCookie 选项,将使用新值更新区域设置 cookie。如果启用了前缀(strategy 除了 no_prefix),将导航到新区域设置的路由。

loadLocaleMessages()

  • 参数
    • locale(类型:string
  • 返回Promise<void>

加载指定区域设置代码的翻译消息。这仅与使用非加载区域设置的延迟加载翻译的项目相关。

getBrowserLocale()

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

返回浏览器区域设置代码,过滤掉选项中定义的区域设置。

finalizePendingLocaleChange()

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

切换到待定的区域设置,该区域设置将在导航时设置,但由于选项 skipSettingLocaleOnNavigate 被阻止。有关更多信息,请参阅 等待页面切换

waitForPendingLocaleChange()

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

返回一个 promise,一旦待定区域设置被设置将被解析。

strategy

  • 类型: Strategies

在选项中指定的路由策略。

defaultDirection

  • 类型Directions

在选项中指定的默认方向。

defaultLocale

  • 类型string

在选项中指定的默认区域设置。

localeCodes

  • 类型Array<string>

已注册区域设置的区域代码列表。

locales

  • 类型Array<string | LocaleObject>

在选项中定义的区域设置列表。

localeProperties

  • 类型LocaleObject

当前区域设置属性的对象。

differentDomains

  • 类型boolean

differentDomains 选项是否启用。