HMCL provides localization support for multiple languages.
This document describes HMCL's support status for these languages and provides a guide for contributors who want to help with HMCL localization.
## Supported languages
Currently, HMCL supports the following languages:
| Language | Language Tag | Preferred Localization Key | Preferred Localization File Suffix | [Game Language Files](https://minecraft.wiki/w/Language) | Support Status | Volunteers |
HMCL uses language tags that conform to the IETF BCP 47 standard.
When choosing language tags, we follow these principles:
1. For languages defined in the ISO 639 standard, if a tag has already been registered in the [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry),
we always use the registered tag.
For example, for English, we use `en` instead of `eng` as the language code.
2. For non-standard languages defined by Minecraft, the code defined in the language file's `language.code` should be preferred over the game language file's name.
This is because Minecraft sometimes uses real-world country/region codes to represent joke languages
(for example, Pirate English uses the language file `en_pt`, but `PT` is actually the country code for Portugal).
For example, for Upside down English, we use `en-Qabs` as the language code instead of `en-UD`.
</details>
<details>
<summary>About Localization Keys and File Suffixes</summary>
Localization file suffixes and keys are used to name [localization resources](#localization-resources).
Generally, the localization key is the language code for the resource, and the localization file suffix is obtained by replacing `-` with `_` in the language code and adding a leading underscore.
As a special case, for default resources, the localization key is `default` and the file suffix is empty.
Due to the existence of the [resource fallback mechanism](#resource-fallback-mechanism),
if there is no resource that exactly matches the current locale,
HMCL will derive a search list from the current language tag and search for resources in order.
We recommend always providing a default resource (with the `default` key and empty file suffix) when providing localization resources,
to ensure all users can load resources properly.
We also recommend using broader language tags for localization resources whenever possible,
so users are less likely to fall back to the default resource.
For example, if you provide a Simplified Chinese localization resource,
we recommend using `zh` as the localization key instead of the more specific `zh-Hans`,
so it will apply to all Chinese users and avoid falling back to the default resource for them.
If you want to provide both Simplified and Traditional Chinese resources,
it is recommended to use the broader `zh` as the key for the resource with more users (as the default Chinese resource),
and use the more specific `zh-Hans`/`zh-Hant` as the key for the resource with fewer users.
</details>
HMCL requires all pull requests that update documentation and localization resources to also update the resources
for all **primary** supported languages.
If the PR author is not familiar with the relevant languages, they can request translation help in the comments,
and maintainers will help translate these texts before merging the PR.
For **secondary** supported languages, we cannot guarantee that these localization resources will always be updated in sync.
We need collaborators who are proficient in these languages to help with maintenance.
We will record volunteers willing to help maintain these language resources in the documentation.
If contributors want to have new localization texts translated into these languages in a timely manner,
they can @ these volunteers in the PR for help.
If you are willing to help maintain localization resources for any language, please open a PR
and add your GitHub username to the volunteer list above.
We greatly appreciate your help.
## Adding Support for a New Language
HMCL welcomes anyone to participate in translation and contribution.
However, maintaining translations for more languages requires more maintenance effort, so we have some requirements for newly added languages.
Please confirm the following requirements before contributing:
- We prioritize [languages officially supported by Minecraft](https://minecraft.wiki/w/Language).
Unless there are special reasons, we do not provide support for languages not yet supported by Minecraft.
- We hope to provide long-term maintenance support for all languages.
Since the maintainers of this project are proficient in only a limited number of languages,
to avoid support for new languages quickly becoming outdated due to lack of maintainers,
we hope to find people proficient in the language to help us maintain the newly added localization files in the long term.
If there may be a lack of long-term maintainers, we will be more cautious about adding support for that language.
We recommend that contributors submit a [feature request](https://github.com/HMCL-dev/HMCL/issues/new?template=feature.yml) before providing a new language translation,
discuss with other contributors first, and determine the future maintenance plan before starting the translation work.
### Getting Started with Translation
If you want to add support for a new language to HMCL, please start by translating [`I18N.properties`](../HMCL/src/main/resources/assets/lang/I18N.properties).
The vast majority of HMCL's texts are in this file, and translating it will translate the entire interface.
This is a Java Properties file, which is very simple in format.
Before translating, please read the introduction to this format: [Properties file](https://en.wikipedia.org/wiki/.properties).
As the first step of translation, please look up the two- or three-letter language tag for your language in [this table](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
For example, the language tag for English is `en`.
After determining the language tag, please create a file named `I18N_<localization file suffix>.properties` (e.g., `I18N_en.properties`) next to the [`I18N.properties` file](../HMCL/src/main/resources/assets/lang).
Then you can start translating in this file.
The `I18N.properties` file follows the [resource fallback mechanism](#resource-fallback-mechanism) to look up missing translations.
That is, you can translate entry by entry, and any untranslated entries will automatically fall back to English.