Skip to content

Limiting available languages

Krzysztof Węgliński edited this page Feb 8, 2025 · 1 revision

Limiting Available Languages

To restrict the available languages for translation services, you can use specific environment variables for each service. Below are the instructions for configuring these settings.

LibreTranslate

LibreTranslate uses standard ISO-639 language codes. To limit the available languages, set the following environment variable:

LIBRETRANSLATE_LANGUAGES=["pl","en"]

If you are unsure of the language codes, you can start the project without this variable and retrieve the list of available codes by accessing:

https://your_app_address/api/libretranslate/languages

This endpoint will return a JSON response with all available codes and names in the following format:

{
  "code": "pl",
  "name": "Polish",
  "targets": [list_of_targets]
}

The code part (e.g., "pl") is what you need to use in your environment variable.

LanguageTool

LanguageTool uses a language-Region format (ISO 639/ISO-3166) for more precise language detection. To limit the available languages, set the following environment variable:

LANGUAGE_TOOL_LANGUAGES=["pl-PL","en-GB"]

If you are unsure of the long codes, you can start the project without this variable and retrieve the list of available long codes by accessing:

https://translate.sth.io/api/languagetool/languages

This endpoint will return a JSON response with all available long codes and names in the following format:

{
  "name": "Polish",
  "code": "pl",
  "longCode": "pl-PL"
}

The longCode part (e.g., "pl-PL") is what you need to use in your environment variable. Note that short codes are also provided, similar to LibreTranslate, but there are multiple regions for many languages (e.g., en-GB, en-US). Therefore, it's important to use the longCode for precision.

By following these instructions, you can effectively limit the available languages for both LibreTranslate and LanguageTool services.

Clone this wiki locally