API
September 6, 2025 · View on GitHub
To avoid unnecessary duplicate document content, some of the documents in this library are linked to the content in
i18n-pro
Thei18n-prorelated link in the current document is based on the3.0.0version. If you are using a different version, you need to check the document corresponding to the version you are using to avoid inconsistent usage
Table of Contents
createI18n
Initialize internationalization state and return its plugin function
It will register the following 3 properties on Vue's global properties. You can click on the links to view their respective types and usage instructions
Type
( props: I18nState & { with$?: boolean }, ) => (app: App) => void
Parameter Description
The other parameters are consistent with the initI18n parameters| Parameter name | Description |
|---|---|
| with$ |
Registered global properties, do you need to bring prefix $ when used The default is TRUE, you can only access the properties through $t, $setI18n, $i18nState ; if configured to false, you can directly access the properties through t, setI18n, i18nState After configuring this property, it will take effect for both Options API and Composition API
|
useI18n
Method to get internationalization state and API in Composition API
Note: Since t and i18nState are reactive states, they need to be accessed with .value when used, like the following:
- t.value('hello world')
- i18nState.value.locale
Type
() => ({
t,
setI18n,
i18nState,
})