Internationalization (i18n)
Usage
Supported since 1.12.0+
- Add the
@EruptI18nannotation to mark all strings in the class as translatable:
java
@EruptI18n
@Erupt(name = "i18n.title")
public class EruptTest {
@EruptField(
views = @View(title = "i18n.name"),
edit = @Edit(title = "i18n.name")
)
private String name;
}Create an
i18ndirectory underresources, then create a CSV file with any name inside it, e.g.:resources/i18n/demo.csvDefine the CSV header. The first column must be
"key", and the remaining columns are locale codes:
key,zh-CN,zh-TW,en-US,fr-FR,ja-JP,ko-KR,ru-RU,es-ES
i18n.name,姓名,姓名,Name,Le nom,名前です,이름,им,Los nombresTranslation is complete — switch the language on the frontend to see the effect.
Calling the translation API manually from the backend:
java
import xyz.erupt.core.i18n.I18nTranslate;
public void translate() {
// Static call; the return value is the translated text based on the frontend user's locale selection
String txt = I18nTranslate.$translate("erupt.exec_success");
}Database Comment Multi-Language Translation
Database comments will be translated according to the default locale configured in
erupt.default-locales.Supported since 1.12.23+
Supported Locale Codes
| Language | Supported Since | Locale Code |
|---|---|---|
| Simplified Chinese | 1.12.0+ | zh-CN |
| Traditional Chinese | 1.12.0+ | zh-TW |
| English | 1.12.0+ | en-US |
| French | 1.12.0+ | fr-FR |
| Japanese | 1.12.0+ | ja-JP |
| Korean | 1.12.0+ | ko-KR |
| Russian | 1.12.0+ | ru-RU |
| Spanish | 1.12.0+ | es-ES |
| German | 1.12.0+ | de-DE |
| Portuguese | 1.12.0+ | pt-PT |
| Indonesian | 1.12.0+ | id-ID |
| Arabic | 1.12.0+ | ar-SA |
