* refactor: rename JSInterop constants * docs: fix typo * fix: server prerendering issue
3.4 KiB
order | title |
---|---|
4 | Internationalization |
The internationalization of Ant Design Blazor
is based on the built-in LocaleProvider
, and localization is based on the CultureInfo.DefaultThreadCurrentUICulture
provided by the blazor framework,
refer to the document ASP.NET Core Blazor globalization and localization for more details.
By default, the current language is fetched from the browser. If you need to use another language, you can configure it at initialization time or change it at run time. Please refer to the following scheme.
localization configuration
// Set current language
LocaleProvider.SetLocale("en-US");
Change locale at run time
Ant Design Blazor
can use CultureInfo.DefaultThreadCurrentUICulture
to dynamically change the localization.
// Changing it anywhere can switch the language of the current thread.
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");
The default is set to "en-US" when the language you set does not have a built-in language pack. You can also add it by using the 'LocaleProvider.SetLocale' method.
// Create a `Locale` object
var zhHK = new Locale { ... };
// Set an additional language
LocaleProvider.SetLocale("zh-HK", zhHK);
Note: en-US
is the package name, follow below.
Built-in languages:
Language | Package Name |
---|---|
Arabic | ar-EG |
Armenian | hy-AM |
Bulgarian | bg-BG |
Catalan | ca-ES |
Czech | cs-CZ |
Denmark | da-DK |
German | de-DE |
Greek | el-GR |
English (Global) | en-GB |
English | en-US |
Spanish | es-ES |
Estonian | et-EE |
Persian | fa-IR |
Finnish | fi-FI |
French (Belgium) | fr-BE |
French (France) | fr-FR |
Hebrew | he-IL |
Croatian | hr-HR |
Hindi | hi-IN |
Hungarian | hu-HU |
Indonesian | id-ID |
Italian | it-IT |
Icelandic | is-IS |
Japanese | ja-JP |
Georgian | ka-GE |
Kannada | kn-IN |
Korean | ko-KR |
Kurdish | ku-IQ |
Latvian | lv-LV |
Malay | ms-MY |
Mongolian | mn-MN |
Norwegian | nb-NO |
Nepal | ne-NP |
Dutch (Belgium) | nl-BE |
Dutch | nl-NL |
Polish | pl-PL |
Portuguese (Brazil) | pt-BR |
Portuguese | pt-PT |
Slovak | sk-SK |
Serbian | sr-RS |
Slovenian | sl-SI |
Swedish | sv-SE |
Tamil | ta-IN |
Thai | th-TH |
Turkish | tr-TR |
Romanian | ro-RO |
Russian | ru-RU |
Ukrainian | uk-UA |
Vietnamese | vi-VN |
Chinese (Simplified) | zh-CN |
Chinese (Traditional) | zh-TW |