public final class Languages extends Object
Modifier and Type | Method and Description |
---|---|
static Language |
addLanguage(String name,
String code,
File dictPath) |
static List<Language> |
get()
Language classes are detected at runtime by searching the classpath for files named
META-INF/org/languagetool/language-module.properties . |
static Language |
getLanguageForLocale(Locale locale)
Get the best match for a locale, using American English as the final fallback if nothing
else fits.
|
static Language |
getLanguageForName(String languageName)
Get the Language object for the given language name.
|
static Language |
getLanguageForShortCode(String langCode)
Get the Language object for the given language code.
|
static Language |
getLanguageForShortCode(String langCode,
List<String> noopLanguageCodes)
Get the Language object for the given language code.
|
static Map<String,Language> |
getLongCodeToLangMapping()
For internal use only.
|
static Language |
getOrAddLanguageByClassName(String className)
Get the Language object for the given language class name or try to create it and add to dynamic languages.
|
static List<Language> |
getWithDemoLanguage()
Like
get() but the list contains also LanguageTool's internal 'Demo'
language, if available. |
static boolean |
isLanguageSupported(String langCode)
Return whether a language with the given language code is supported.
|
public static List<Language> get()
META-INF/org/languagetool/language-module.properties
. Those file(s)
need to contain a key languageClasses
which specifies the fully qualified
class name(s), e.g. org.languagetool.language.English
. Use commas to specify
more than one class.public static List<Language> getWithDemoLanguage()
get()
but the list contains also LanguageTool's internal 'Demo'
language, if available. Only useful for tests.public static Language getOrAddLanguageByClassName(String className)
className
- e.g. org.languagetool.language.English
RuntimeException
- if language not found in classpath@Nullable public static Language getLanguageForName(String languageName)
languageName
- e.g. English
or German
(case is significant)null
if there is no such languagepublic static Language getLanguageForShortCode(String langCode)
langCode
- e.g. en
or en-US
IllegalArgumentException
- if the language is not supported or if the language code is invalidpublic static Language getLanguageForShortCode(String langCode, List<String> noopLanguageCodes)
langCode
- e.g. en
or en-US
noopLanguageCodes
- 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)IllegalArgumentException
- if the language is not supported or if the language code is invalidpublic static boolean isLanguageSupported(String langCode)
Language
object is initialized.langCode
- e.g. en
or en-US
IllegalArgumentException
- in some cases of an invalid language code formatpublic static Language getLanguageForLocale(Locale locale)
RuntimeException
- if no language was found and American English as a fallback is not available