Skip to content

Internationalization

Wot UI uses Chinese language by default and supports multi-language switching. If you want to use other languages, you can refer to the following solutions.

Note

Currently, Vite will cache pre-built dependencies to node_modules/.vite. The internationalization implementation of the component library is based on data sharing implemented by reactive. In the dev stage, the page will use internationalization data in pre-built products, while the component library uses internationalization data inside the component library, so when not introduced in uni_modules mode, you need to add the following configuration in vite.config.ts:

ts
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'

export default defineConfig({
  ...
  optimizeDeps: {
    exclude: ['@wot-ui/ui']
  }
  ...
})

Use optimizeDeps.exclude to force exclude the @wot-ui/ui module in pre-building. In uni_modules mode, no processing is required.

Using Other Languages

We implement multi-language support through the Locale component. Use the Locale.use method to switch the current language.

typescript
import { Locale } from '@wot-ui/ui'
// Import English language pack
import enUS from '@wot-ui/ui/locale/lang/en-US'

Locale.use('en-US', enUS)

Overriding Language Packs

Copy modification and extension of copy can be achieved through the Locale.add method, as shown in the following example:

typescript
import { Locale } from '@wot-ui/ui'

const messages = {
  'zh-CN': {
    calendar: {
      title: 'Please select date' // Change 'Select date' to 'Please select date'
    }
  }
}

Locale.add(messages)

Supported Languages

LanguageFilenameVersion
Simplified Chinesezh-CNv0.2.20
Traditional Chinese (Taiwan)zh-TWv0.2.20
Traditional Chinese (Hong Kong)zh-HKv0.2.20
Englishen-USv0.2.20
Thaith-THv0.2.20
Vietnamesevi-VNv0.2.20
Arabicar-SAv1.3.12
Germande-DEv1.3.12
Spanishes-ESv1.3.12
Portuguesept-PTv1.3.12
Frenchfr-FRv1.3.12
Japaneseja-JPv1.3.12
Koreanko-KRv1.3.12
Turkishtr-TRv1.3.12
Russianru-RUv1.3.12

If you need to use other languages, welcome to contribute PR. Just add a language configuration file here.

Released under the MIT License.

Released under the MIT License.