Class WikimediaLanguageCodes
java.lang.Object
org.wikidata.wdtk.datamodel.interfaces.WikimediaLanguageCodes
This class helps to interpret Wikimedia language codes in terms of official
BCP 47 language
codes. Unforatunately, the two systems don't agree in all cases. This class
incorporates several exceptions, where Wikimedia uses non-standard language
codes, including but not limited to the documented exceptional
language codes. When available, the IANA-registered codes are used, but in some cases new codes are
constructed according to the standard rules.
- Author:
- Markus Kroetzsch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
fixLanguageCodeIfDeprecated
(String wikimediaLanguageCode) Translate a Wikimedia language code to its preferred value if this code is deprecated, or return it untouched if the string is not a known deprecated Wikimedia language codestatic String
getLanguageCode
(String wikimediaLanguageCode) Get a BCP 47 language code for the given Wikimedia language code.
-
Constructor Details
-
WikimediaLanguageCodes
public WikimediaLanguageCodes()
-
-
Method Details
-
getLanguageCode
Get a BCP 47 language code for the given Wikimedia language code.- Parameters:
wikimediaLanguageCode
- the language code as used by Wikimedia- Returns:
- the BCP 47 language code
- Throws:
IllegalArgumentException
- if the given Wikimedia language code is not known. In particular, the method will not assume that unknown codes agree with BCP 47 by default (since they have no reason to do this).
-
fixLanguageCodeIfDeprecated
Translate a Wikimedia language code to its preferred value if this code is deprecated, or return it untouched if the string is not a known deprecated Wikimedia language code- Parameters:
wikimediaLanguageCode
- the language code as used by Wikimedia- Returns:
- the preferred language code corresponding to the original language code
-