Package org.languagetool
Class Languages
java.lang.Object
org.languagetool.Languages
Helper methods to list all supported languages and to get language objects
by their name or language code etc.
- Since:
- 2.9
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LanguageaddLanguage(String name, String code, File dictPath) private static LanguagecreateLanguageObjects(URL url, String className) get()Language classes are detected at runtime by searching the classpath for files namedMETA-INF/org/languagetool/language-module.properties.private static Languageprivate static LanguagegetLanguageForLanguageNameOnly(Locale locale) static LanguagegetLanguageForLocale(Locale locale) Get the best match for a locale, using American English as the final fallback if nothing else fits.static LanguagegetLanguageForName(String languageName) Get the Language object for the given language name.static LanguagegetLanguageForShortCode(String langCode) Get the Language object for the given language code.static LanguagegetLanguageForShortCode(String langCode, List<String> noopLanguageCodes) Get the Language object for the given language code.private static LanguagegetLanguageForShortCodeOrNull(String langCode) For internal use only. Returns a mapping fromfr-FRto its language etc.static LanguagegetOrAddLanguageByClassName(String className) Get the Language object for the given language class name or try to create it and add to dynamic languages.Likeget()but the list contains also LanguageTool's internal 'Demo' language, if available.(package private) static booleanhasPremium(String className) static booleanisLanguageSupported(String langCode) Return whether a language with the given language code is supported.
-
Field Details
-
PROPERTIES_PATH
- See Also:
-
PROPERTIES_KEY
- See Also:
-
NOOP_LANGUAGE
-
languages
-
dynLanguages
-
staticAndDynamicLanguages
-
staticAndDynamicLanguagesImmutable
-
-
Constructor Details
-
Languages
private Languages()
-
-
Method Details
-
addLanguage
- Since:
- 4.5
-
get
Language classes are detected at runtime by searching the classpath for files namedMETA-INF/org/languagetool/language-module.properties. Those file(s) need to contain a keylanguageClasseswhich specifies the fully qualified class name(s), e.g.org.languagetool.language.English. Use commas to specify more than one class.- Returns:
- an unmodifiable list of all supported languages
-
getWithDemoLanguage
Likeget()but the list contains also LanguageTool's internal 'Demo' language, if available. Only useful for tests.- Returns:
- an unmodifiable list
-
getStaticAndDynamicLanguages
-
getAllLanguages
-
createLanguageObjects
-
hasPremium
-
getOrAddLanguageByClassName
Get the Language object for the given language class name or try to create it and add to dynamic languages.- Parameters:
className- e.g.org.languagetool.language.English- Returns:
- a Language object
- Throws:
RuntimeException- if language not found in classpath- Since:
- 5.0
-
getLanguageForName
Get the Language object for the given language name.- Parameters:
languageName- e.g.EnglishorGerman(case is significant)- Returns:
- a Language object or
nullif there is no such language
-
getLanguageForShortCode
Get the Language object for the given language code.- Parameters:
langCode- e.g.enoren-US- Throws:
IllegalArgumentException- if the language is not supported or if the language code is invalid- Since:
- 3.6
-
getLanguageForShortCode
Get the Language object for the given language code.- Parameters:
langCode- e.g.enoren-USnoopLanguageCodes- list of languages that can be detected but that will not actually find any errors (can be used so non-supported languages are not detected as some other language)- Throws:
IllegalArgumentException- if the language is not supported or if the language code is invalid- Since:
- 4.4
-
getLangCodes
-
isLanguageSupported
Return whether a language with the given language code is supported. Which languages are supported depends on the classpath when theLanguageobject is initialized.- Parameters:
langCode- e.g.enoren-US- Returns:
- true if the language is supported
- Throws:
IllegalArgumentException- in some cases of an invalid language code format
-
getLanguageForLocale
Get the best match for a locale, using American English as the final fallback if nothing else fits. The returned language will be a country variant language (e.g. British English, not just English) if available. Note: this does not consider languages added dynamically- Throws:
RuntimeException- if no language was found and American English as a fallback is not available
-
getLongCodeToLangMapping
For internal use only. Returns a mapping fromfr-FRto its language etc. Used to support requests from LibreOffice 7.4, which sends these language codes. -
getLanguageForShortCodeOrNull
-
getLanguageForLanguageNameAndCountry
-
getLanguageForLanguageNameOnly
-