LibJF/docs/libjf-translate-v1.md

2.6 KiB

libjf-translate-v1

libjf-translate-v1 provides a utility class for translating strings through user-configurable services.

To use this, first obtain a TranslateService instance. You can use TranslateService.getConfigured() to do so. Please be aware that due to the nature of java generics, using var instead of a specific type for instances is recommended. You can also directly access implementations, however, this is not recommended and is not subject to the API stability promise. The TranslateService interface exposes all relevant functionality.

TranslateService::

Name Explanation
static TranslateService<?> getConfigured() Returns the TranslateService the user configured. Implementations may change without notice.
static List<TranslateService<?>> getAvailable() Returns all available TranslateServices. Please use getConfigured() instead where possible.
String translate(String textToTranslate, T translateFrom, T translateTo Translates a string from the specified source language (or null to auto-detect) to the target language.
T detect(String text) Detects the language used in the specified string.
T parseLang(Stirng lang) Gets the language for the specified ID
List<T> getAvailableLanguages() Get all available languages for the configured service.
String getName() Get the name of this translate service.

Language:

Name Explanation
String getDisplayName() Returns the string to show in UIs for this language
String getIdentifier() Returns the ID for internal use (TranslateService.parseLang for example)