Skip to content

Internationalization0.2.20

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

Note

Currently, the package published on npm is uncompiled vue and ts. Vite will cache pre-built dependencies in node_modules/.vite. The component library's internationalization is implemented based on reactive for data sharing. During the dev stage, the page will use internationalization data from the pre-built product, while the component library uses its internal internationalization data. Therefore, when importing in non-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: process.env.UNI_PLATFORM === 'h5' && process.env.NODE_ENV === 'development' ? ['wot-design-uni'] : []
  }
  ...
})

Use optimizeDeps.exclude to forcibly exclude the wot-design-uni module from pre-building. In uni_modules mode, no processing is needed.

Using Other Languages

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

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

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

Override Language Pack

You can modify and extend the text through the Locale.add method, for example:

typescript
import { Locale } from 'wot-design-uni'

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

Locale.add(messages)

Supported Languages

LanguageFile NameVersion
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, you are welcome to contribute a PR. Just add a language configuration file here.

Released under the MIT License.

Released under the MIT License.