fix(translate): don't initialize LibreTranslate if we can avoid it
This commit is contained in:
parent
ef6c58e93d
commit
45f101f9ec
|
@ -53,10 +53,12 @@ public interface TranslateService<T extends Language> {
|
|||
} catch (URISyntaxException | IOException e) {
|
||||
LibJf.LOGGER.error("Could not create Google Translate service", e);
|
||||
}
|
||||
try {
|
||||
result.add(LibreTranslateService.get(TranslateConfig.libreTranslateHost));
|
||||
} catch (TranslateException e) {
|
||||
LibJf.LOGGER.error("Could not create LibreTranslate service", e);
|
||||
if (TranslateConfig.libreTranslateHost != null) {
|
||||
try {
|
||||
result.add(LibreTranslateService.get(TranslateConfig.libreTranslateHost));
|
||||
} catch (TranslateException e) {
|
||||
LibJf.LOGGER.error("Could not create LibreTranslate service", e);
|
||||
}
|
||||
}
|
||||
result.add(NoopTranslateService.INSTANCE);
|
||||
return List.copyOf(result);
|
||||
|
|
|
@ -8,12 +8,12 @@ import io.gitlab.jfronny.libjf.translate.impl.libretranslate.LibreTranslateServi
|
|||
|
||||
public class TranslateConfig implements JfCustomConfig {
|
||||
public static String translationService = GoogleTranslateService.NAME;
|
||||
public static String libreTranslateHost = "https://translate.argosopentech.com";
|
||||
public static String libreTranslateHost = null;
|
||||
|
||||
public static void ensureValid() {
|
||||
if (translationService == null) translationService = GoogleTranslateService.NAME;
|
||||
if (translationService.equals(LibreTranslateService.NAME) && libreTranslateHost == null || libreTranslateHost.isBlank())
|
||||
libreTranslateHost = "https://translate.argosopentech.com";
|
||||
translationService = GoogleTranslateService.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue