ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
59 lines (44 loc) • 1.43 kB
Markdown
order: 2
title: Internationalization
type: Documents
Provide a uniform localization support for `@ohayo/*` class library built-in text of components.
## Usage
### Providers
Provides the token of `OHAYO_LOCALE` for configuring antd locale text globally.
```ts
import { OHAYO_LOCALE, en_US } from '@ohayo/theme';
@NgModule({
...
providers : [ { provide: OHAYO_LOCALE, useValue: en_US } ]
})
export class AppModule { }
```
### Service
Provides the service of `OhayoLocaleService` to dynamic change the locale text.
```ts
import { en_US, OhayoLocaleService } from '@ohayo/theme';
...
constructor(private ohayoLocaleService: OhayoLocaleService) {
}
switchLanguage() {
this.ohayoLocaleService.setLocale(en_US);
}
```
Note: `en_US` is the package name, follow below.
## Supported languages
| Language | Filename |
|----------|----------|
| English | en_US |
| Chinese (Simplified) | zh_CN |
| Chinese (Traditional) | zh_TW |
| Turkish | tr_TR |
| Polish | pl_PL |
| Greek | el_GR |
| Korean | ko_KR |
| Croatian | hr_HR |
| Japanese | ja_JP |
| Slovenian | sl_SI |
## Add a new language
If you can't find your language, you are welcome to create a locale package based on [en_US](https://github.com/ohayojp/ohayo/tree/master/packages/theme/src/locale/languages/en-US.ts) (You can also refer to [#308](https://github.com/ohayojp/ohayo/pull/308) to contribute language package to us) and send us a pull request.