LibreOffice Module i18nlangtag (master) 1
|
Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and conversions in between. More...
#include <languagetag.hxx>
Public Types | |
enum class | ScriptType { UNKNOWN = 0 , WESTERN = 1 , CJK = 2 , CTL = 3 , RTL = 4 } |
ScriptType for a language. More... | |
enum | PrivateUse { ALLOW = 0 , DISALLOW , ALLOW_ART_X } |
Enums to be used with isValidBcp47(). More... | |
typedef std::shared_ptr< LanguageTagImpl > | ImplPtr |
Public Member Functions | |
LanguageTag (const OUString &rBcp47LanguageTag, bool bCanonicalize=false) | |
Init LanguageTag with existing BCP 47 language tag string. More... | |
LanguageTag (const css::lang::Locale &rLocale) | |
Init LanguageTag with Locale. More... | |
LanguageTag (LanguageType nLanguage) | |
Init LanguageTag with LanguageType MS-LangID. More... | |
LanguageTag (const OUString &rBcp47, const OUString &rLanguage, std::u16string_view rScript, const OUString &rCountry) | |
Init LanguageTag with either BCP 47 language tag (precedence if not empty), or a combination of language, script and country. More... | |
LanguageTag (const rtl_Locale &rLocale) | |
Init LanguageTag with rtl_Locale. More... | |
~LanguageTag () | |
LanguageTag (LanguageTag const &)=default | |
LanguageTag (LanguageTag &&)=default | |
LanguageTag & | operator= (LanguageTag const &)=default |
LanguageTag & | operator= (LanguageTag &&)=default |
const OUString & | getBcp47 (bool bResolveSystem=true) const |
Obtain BCP 47 language tag. More... | |
OUString | getBcp47MS () const |
Obtain BCP 47 language tag, but with MS malformed exceptions. More... | |
const css::lang::Locale & | getLocale (bool bResolveSystem=true) const |
Obtain language tag as Locale. More... | |
LanguageType | getLanguageType (bool bResolveSystem=true) const |
Obtain mapping to MS-LangID. More... | |
void | getIsoLanguageScriptCountry (OUString &rLanguage, OUString &rScript, OUString &rCountry) const |
Obtain ISO strings for language, script and country. More... | |
OUString | getLanguage () const |
Get ISO 639 language code, or BCP 47 language. More... | |
OUString | getScript () const |
Get ISO 15924 script code, if not the default script according to BCP 47. More... | |
OUString | getLanguageAndScript () const |
Get combined language and script code, separated by '-' if non-default script, if default script only language. More... | |
OUString | getCountry () const |
Get ISO 3166 country alpha code. More... | |
OUString | getVariants () const |
Get BCP 47 variant subtags, of the IANA Language Subtag Registry. More... | |
OUString | getGlibcLocaleString (std::u16string_view rEncoding) const |
Get a GLIBC locale string. More... | |
bool | hasScript () const |
If language tag has a non-default script specified. More... | |
bool | isIsoLocale () const |
If language tag is a locale that can be expressed using only ISO 639 language codes and ISO 3166 country codes, thus is convertible to a conforming Locale struct without using extension mechanisms. More... | |
bool | isIsoODF () const |
If language tag is a locale that can be expressed using only ISO 639 language codes and ISO 15924 script codes and ISO 3166 country codes, thus can be stored in an ODF document using only fo:language, fo:script and fo:country attributes. More... | |
bool | isValidBcp47 () const |
If this is a valid BCP 47 language tag. More... | |
bool | isSystemLocale () const |
If this tag was constructed as an empty tag denoting the system locale. More... | |
ScriptType | getScriptType () const |
Returns the script type for this language, UNKNOWN if not set. More... | |
void | setScriptType (ScriptType st) |
Sets the script type for this language. More... | |
LanguageTag & | reset (const OUString &rBcp47LanguageTag) |
Reset with existing BCP 47 language tag string. More... | |
LanguageTag & | reset (const css::lang::Locale &rLocale) |
Reset with Locale. More... | |
LanguageTag & | reset (LanguageType nLanguage) |
Reset with LanguageType MS-LangID. More... | |
LanguageTag & | makeFallback () |
Fall back to a known locale. More... | |
::std::vector< OUString > | getFallbackStrings (bool bIncludeFullBcp47) const |
Return a vector of fall-back strings. More... | |
bool | equals (const LanguageTag &rLanguageTag) const |
Test equality of two LanguageTag, possibly resolving system locale. More... | |
bool | operator== (const LanguageTag &rLanguageTag) const |
Test equality of two LanguageTag. More... | |
bool | operator!= (const LanguageTag &rLanguageTag) const |
Test inequality of two LanguageTag. More... | |
bool | operator< (const LanguageTag &rLanguageTag) const |
Test this LanguageTag less than that LanguageTag. More... | |
Static Public Member Functions | |
::std::vector< OUString >::const_iterator | getFallback (const ::std::vector< OUString > &rList, const OUString &rReference) |
Search for an equal or at least for a similar locale in a list of possible ones. More... | |
::std::vector< css::lang::Locale >::const_iterator | getMatchingFallback (const ::std::vector< css::lang::Locale > &rList, const css::lang::Locale &rReference) |
Search for an equal or for a similar locale in a list of possible ones where at least the language matches. More... | |
static css::lang::Locale | convertToLocale (LanguageType nLangID, bool bResolveSystem=true) |
Convert MS-LangID to Locale. More... | |
static LanguageType | convertToLanguageType (const css::lang::Locale &rLocale, bool bResolveSystem=true) |
Convert Locale to MS-LangID. More... | |
static OUString | convertToBcp47 (LanguageType nLangID) |
Convert MS-LangID to BCP 47 string. More... | |
static OUString | convertToBcp47 (const css::lang::Locale &rLocale, bool bResolveSystem=true) |
Convert Locale to BCP 47 string. More... | |
static css::lang::Locale | convertToLocale (const OUString &rBcp47, bool bResolveSystem=true) |
Convert BCP 47 string to Locale, convenience method. More... | |
static LanguageType | convertToLanguageType (const OUString &rBcp47) |
Convert BCP 47 string to MS-LangID, convenience method. More... | |
static LanguageType | convertToLanguageTypeWithFallback (const OUString &rBcp47) |
Convert BCP 47 string to MS-LangID with fallback, convenience method. More... | |
static css::lang::Locale | convertToLocaleWithFallback (const OUString &rBcp47) |
Convert BCP 47 string to Locale with fallback, convenience method. More... | |
static LanguageType | convertToLanguageTypeWithFallback (const css::lang::Locale &rLocale) |
Convert Locale to MS-LangID with fallback. More... | |
static bool | isValidBcp47 (const OUString &rString, OUString *o_pCanonicalized, PrivateUse ePrivateUse=PrivateUse::ALLOW) |
If rString represents a valid BCP 47 language tag. More... | |
static bool | isOnTheFlyID (LanguageType nLang) |
If nLang is a generated on-the-fly LangID. More... | |
static ScriptType | getOnTheFlyScriptType (LanguageType nLang) |
static void | setConfiguredSystemLanguage (LanguageType nLang) |
@ATTENTION: ONLY to be called by the application's configuration! More... | |
static void | disable_lt_tag_parse () |
@ATTENTION: ONLY to be called by fuzzing setup More... | |
Private Member Functions | |
LanguageTagImpl * | getImpl () |
LanguageTagImpl const * | getImpl () const |
ImplPtr | registerImpl () const |
void | syncFromImpl () |
void | syncVarsFromRawImpl () const |
void | syncVarsFromImpl () const |
void | convertLocaleToLang () |
void | convertBcp47ToLocale () |
void | convertBcp47ToLang () |
void | convertLangToLocale () |
void | convertFromRtlLocale () |
bool | synCanonicalize () |
Canonicalize if not yet done and synchronize initialized conversions. More... | |
void | resetVars () |
Static Private Member Functions | |
static bool | isIsoLanguage (const OUString &rLanguage) |
static bool | isIsoScript (const OUString &rScript) |
static bool | isIsoCountry (const OUString &rRegion) |
Private Attributes | |
css::lang::Locale | maLocale |
OUString | maBcp47 |
LanguageType | mnLangID |
ImplPtr | mpImpl |
bool | mbSystemLocale: 1 |
bool | mbInitializedBcp47: 1 |
bool | mbInitializedLocale: 1 |
bool | mbInitializedLangID: 1 |
bool | mbIsFallback: 1 |
Friends | |
class | LanguageTagImpl |
Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and conversions in between.
Note that member variables are mutable and may change their values even in const methods. Getter methods return either the original value or matching converted values.
For standalone conversions if no LanguageTag instance is at hand, static convertTo...() methods exist.
Definition at line 52 of file languagetag.hxx.
typedef std::shared_ptr< LanguageTagImpl > LanguageTag::ImplPtr |
Definition at line 557 of file languagetag.hxx.
Enums to be used with isValidBcp47().
Definition at line 519 of file languagetag.hxx.
|
strong |
ScriptType for a language.
Used only in onTheFly languages as a way of marking key script behaviours for the script of the language without having to store and analyse the script each time. Used primarily from msLangId.
These need to correspond to the ExtraLanguages.ScriptType template property in officecfg/registry/schema/org/openoffice/VCL.xcs
Enumerator | |
---|---|
UNKNOWN | |
WESTERN | |
CJK | |
CTL | |
RTL |
Definition at line 67 of file languagetag.hxx.
|
explicit |
Init LanguageTag with existing BCP 47 language tag string.
bCanonicalize | If TRUE, canonicalize tag and reparse, the resulting tag string may be different. IF FALSE, the tag is simply stored and can be retrieved with getBcp47(). |
Note that conversions to ISO codes, locales or LanguageType or obtaining language or script will canonicalize the tag string anyway, so specifying bCanonicalize=false is not a guarantee that the tag will stay identical to what was passed.
Definition at line 501 of file languagetag.cxx.
References LanguageTagImpl::canonicalize(), getImpl(), and syncFromImpl().
Referenced by convertToLanguageType(), convertToLanguageTypeWithFallback(), convertToLocale(), convertToLocaleWithFallback(), getFallback(), getFallbackStrings(), getMatchingFallback(), and makeFallback().
|
explicit |
Init LanguageTag with Locale.
Definition at line 522 of file languagetag.cxx.
References handleVendorVariant(), and maLocale.
|
explicit |
Init LanguageTag with LanguageType MS-LangID.
Definition at line 536 of file languagetag.cxx.
|
explicit |
Init LanguageTag with either BCP 47 language tag (precedence if not empty), or a combination of language, script and country.
This is a convenience ctor to be used in ODF import where these are distinct attributes.
Definition at line 548 of file languagetag.cxx.
References I18NLANGTAG_QLT, maBcp47, maLocale, mbInitializedBcp47, mbInitializedLocale, and mbSystemLocale.
|
explicit |
Init LanguageTag with rtl_Locale.
This is a convenience ctor.
Definition at line 585 of file languagetag.cxx.
References convertFromRtlLocale(), Country, and Variant.
LanguageTag::~LanguageTag | ( | ) |
Definition at line 598 of file languagetag.cxx.
|
default |
|
default |
|
private |
Definition at line 1493 of file languagetag.cxx.
References LanguageTagImpl::convertBcp47ToLang(), getImpl(), and syncFromImpl().
Referenced by getLanguageType().
|
private |
Definition at line 1470 of file languagetag.cxx.
References LanguageTagImpl::convertBcp47ToLocale(), getImpl(), and syncFromImpl().
Referenced by getLocale().
|
private |
Definition at line 1529 of file languagetag.cxx.
References aStr, MsLangId::convertUnxByteStringToLanguage(), LANGUAGE_DONTKNOW, LANGUAGE_ENGLISH_US, maBcp47, maLocale, mbInitializedBcp47, mbInitializedLangID, mbInitializedLocale, mnLangID, OUStringToOString(), and SAL_WARN.
Referenced by LanguageTag().
|
private |
Definition at line 1513 of file languagetag.cxx.
References LanguageTagImpl::convertLangToLocale(), getImpl(), and syncFromImpl().
Referenced by getLocale().
|
private |
Definition at line 1444 of file languagetag.cxx.
References LanguageTagImpl::convertLocaleToLang(), getImpl(), and syncFromImpl().
Referenced by getLanguageType().
|
static |
Convert Locale to BCP 47 string.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return an empty OUString for such a tag. |
Definition at line 2859 of file languagetag.cxx.
References LanguageTagImpl::convertToBcp47(), convertToBcp47(), and LANGUAGE_SYSTEM.
|
static |
Convert MS-LangID to BCP 47 string.
Resolve an empty language tag denoting the system locale to the real locale used.
Definition at line 2877 of file languagetag.cxx.
References LanguageTagImpl::convertToBcp47(), and convertToLocale().
Referenced by LanguageTagImpl::convertLocaleToBcp47(), and convertToBcp47().
|
static |
Convert Locale to MS-LangID.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return LANGUAGE_SYSTEM for such a tag. |
Definition at line 2821 of file languagetag.cxx.
References LANGUAGE_SYSTEM, and LanguageTag().
|
static |
Convert BCP 47 string to MS-LangID, convenience method.
NOTE: exists only for consistency with the other convertTo...() methods, internally uses a temporary LanguageTag instance for conversion so does not save anything compared to LanguageTag(rBcp47).getLanguageType(bResolveSystem).
Resolve an empty language tag denoting the system locale to the real locale used.
Definition at line 2900 of file languagetag.cxx.
References LanguageTag().
|
static |
Convert Locale to MS-LangID with fallback.
Resolves an empty language tag denoting the system locale to LANGUAGE_SYSTEM and does not fallback.
Definition at line 2921 of file languagetag.cxx.
References LANGUAGE_SYSTEM, and LanguageTag().
|
static |
Convert BCP 47 string to MS-LangID with fallback, convenience method.
NOTE: exists only for consistency with the other convertTo...() methods, internally uses a temporary LanguageTag instance for conversion so does not save anything compared to LanguageTag(rBcp47).makeFallback().getLanguageType(bResolveSystem).
Always resolves an empty tag to the system locale.
Definition at line 2907 of file languagetag.cxx.
References LanguageTag().
|
static |
Convert BCP 47 string to Locale, convenience method.
NOTE: exists only for consistency with the other convertTo...() methods, internally uses a temporary LanguageTag instance for conversion so does not save anything compared to LanguageTag(rBcp47).getLocale(bResolveSystem).
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return an empty Locale for such a tag. |
Definition at line 2890 of file languagetag.cxx.
References LanguageTag().
|
static |
Convert MS-LangID to Locale.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return an empty Locale for such a tag. |
Definition at line 2811 of file languagetag.cxx.
References LanguageTag(), and lcl_isSystem().
Referenced by convertToBcp47().
|
static |
Convert BCP 47 string to Locale with fallback, convenience method.
NOTE: exists only for consistency with the other convertTo...() methods, internally uses a temporary LanguageTag instance for conversion so does not save anything compared to LanguageTag(rBcp47).makeFallback().getLocale(bResolveSystem).
Always resolves an empty tag to the system locale.
Definition at line 2914 of file languagetag.cxx.
References LanguageTag().
|
static |
@ATTENTION: ONLY to be called by fuzzing setup
Definition at line 739 of file languagetag.cxx.
References lt_tag_parse_disabled.
bool LanguageTag::equals | ( | const LanguageTag & | rLanguageTag | ) | const |
Test equality of two LanguageTag, possibly resolving system locale.
Resolve empty language tags denoting the system locale to the real locale used before comparing.
Definition at line 2405 of file languagetag.cxx.
References getBcp47(), isSystemLocale(), and operator==().
const OUString & LanguageTag::getBcp47 | ( | bool | bResolveSystem = true | ) | const |
Obtain BCP 47 language tag.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return an empty OUString for such a tag. |
Definition at line 1582 of file languagetag.cxx.
References LanguageTagImpl::getBcp47(), getImpl(), maBcp47, mbInitializedBcp47, mbSystemLocale, syncFromImpl(), syncVarsFromImpl(), and u.
Referenced by equals(), getBcp47MS(), getFallbackStrings(), LanguageTagIcu::getIcuLocale(), operator<(), and operator==().
OUString LanguageTag::getBcp47MS | ( | ) | const |
Obtain BCP 47 language tag, but with MS malformed exceptions.
To be used only in OOXML filter context. For example, es-ES-u-co-trad is stored as es-ES_tradnl which is not a valid BCP 47 language tag.
Definition at line 2397 of file languagetag.cxx.
References getBcp47(), getLanguageType(), and LANGUAGE_SPANISH_DATED.
OUString LanguageTag::getCountry | ( | ) | const |
Get ISO 3166 country alpha code.
Empty if the BCP 47 tags denote a region not expressible as 2 character country code.
Always resolves an empty tag to the system locale.
Definition at line 1917 of file languagetag.cxx.
References LanguageTagImpl::getCountry(), getImpl(), LanguageTagImpl::maCachedCountry, LanguageTagImpl::mbCachedCountry, and syncFromImpl().
Referenced by getFallbackStrings(), getGlibcLocaleString(), LanguageTagIcu::getIcuLocale(), and getIsoLanguageScriptCountry().
|
static |
Search for an equal or at least for a similar locale in a list of possible ones.
@descr First search for a locale that is equal to the reference locale. (means: same BCP47 string)
If the reference locale could not be located, check for "similar" locales, in the same order as obtained by getFallbackStrings().
If no similar locale could be located, we search for a locale "en-US" inside the given locale list.
If "en-US" could not be located, we search for a locale "en" inside the given list.
If no "same" nor any "similar" locale could be found, we try "x-default" and "x-no-translate" explicitly. Sometimes variables don't use real localization. For example, in case the localized value is a fix product name.
If no locale matched until then, we use any other locale that exists inside the set of given ones, namely the first encountered!
rList | the vector of possible locales as BCP47 strings. |
rReference | the reference locale, BCP47 string. |
Definition at line 2713 of file languagetag.cxx.
References getFallbackStrings(), and LanguageTag().
std::vector< OUString > LanguageTag::getFallbackStrings | ( | bool | bIncludeFullBcp47 | ) | const |
Return a vector of fall-back strings.
In order: full BCP 47 tag, same as getBcp47() lll-Ssss-CC lll-Ssss lll-CC lll
If the tag includes variants the order is: full BCP 47 tag, same as getBcp47() lll-Ssss-CC-vvvvvvvv lll-Ssss-vvvvvvvv lll-Ssss-CC lll-Ssss lll-CC-vvvvvvvv lll-vvvvvvvv lll-CC lll
Only strings that differ from a higher order are included, for example if there is no script the elements will be bcp47, lll-CC, lll; if the bcp47 string is identical to lll-CC then only lll-CC, lll.
Note that lll is only ISO 639-1/2 alpha code and CC is only ISO 3166 alpha code. If the region can not be expressed as ISO 3166 then no -CC tags are included.
bIncludeFullBcp47 | If TRUE, the full BCP 47 tag is included as first element. If FALSE, the full tag is not included; used if the caller obtains the fallbacks only if the full tag did not lead to a match, so subsequent tries need not to include it again. |
Definition at line 2176 of file languagetag.cxx.
References getBcp47(), getCountry(), getFallbackStrings(), getLanguage(), getScript(), getVariants(), hasScript(), isIsoLocale(), LanguageTag(), and maBcp47.
Referenced by getFallback(), getFallbackStrings(), getKnowns(), getMatchingFallback(), and makeFallback().
OUString LanguageTag::getGlibcLocaleString | ( | std::u16string_view | rEncoding | ) | const |
Get a GLIBC locale string.
Always resolves an empty tag to the system locale.
rEncoding | An encoding to be appended to language_country, for example ".UTF-8" including the dot. |
Definition at line 1978 of file languagetag.cxx.
References getCountry(), LanguageTagImpl::getGlibcLocaleString(), getImpl(), getLanguage(), and isIsoLocale().
|
private |
Definition at line 1030 of file languagetag.cxx.
References mpImpl, registerImpl(), and syncVarsFromRawImpl().
Referenced by convertBcp47ToLang(), convertBcp47ToLocale(), convertLangToLocale(), convertLocaleToLang(), getBcp47(), getCountry(), getGlibcLocaleString(), getLanguage(), getScript(), getScriptType(), getVariants(), hasScript(), isIsoLocale(), isIsoODF(), isValidBcp47(), LanguageTag(), setScriptType(), synCanonicalize(), syncFromImpl(), and syncVarsFromImpl().
|
private |
Definition at line 1020 of file languagetag.cxx.
References mpImpl, registerImpl(), and syncVarsFromRawImpl().
void LanguageTag::getIsoLanguageScriptCountry | ( | OUString & | rLanguage, |
OUString & | rScript, | ||
OUString & | rCountry | ||
) | const |
Obtain ISO strings for language, script and country.
This is a convenience method for ODF export places only. Avoid use in other code.
ATTENTION! May return empty strings if the language tag is not expressible in valid ISO codes!
Always resolves an empty tag to the system locale.
Definition at line 1766 of file languagetag.cxx.
References getCountry(), getLanguage(), getScript(), isIsoCountry(), isIsoLanguage(), isIsoODF(), and isIsoScript().
OUString LanguageTag::getLanguage | ( | ) | const |
Get ISO 639 language code, or BCP 47 language.
Always resolves an empty tag to the system locale.
Definition at line 1859 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::getLanguage(), LanguageTagImpl::maCachedLanguage, LanguageTagImpl::mbCachedLanguage, and syncFromImpl().
Referenced by getFallbackStrings(), getGlibcLocaleString(), LanguageTagIcu::getIcuLocale(), getIsoLanguageScriptCountry(), and getLanguageAndScript().
OUString LanguageTag::getLanguageAndScript | ( | ) | const |
Get combined language and script code, separated by '-' if non-default script, if default script only language.
Always resolves an empty tag to the system locale.
Definition at line 1892 of file languagetag.cxx.
References getLanguage(), and getScript().
LanguageType LanguageTag::getLanguageType | ( | bool | bResolveSystem = true | ) | const |
Obtain mapping to MS-LangID.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return LANGUAGE_SYSTEM for such a tag. |
Definition at line 1740 of file languagetag.cxx.
References convertBcp47ToLang(), convertLocaleToLang(), LANGUAGE_DONTKNOW, LANGUAGE_SYSTEM, mbInitializedBcp47, mbInitializedLangID, mbSystemLocale, mnLangID, synCanonicalize(), and syncVarsFromImpl().
Referenced by MsLangId::Conversion::convertIsoNamesToLanguage(), getBcp47MS(), and getPlatformSystemLanguageImpl().
const css::lang::Locale & LanguageTag::getLocale | ( | bool | bResolveSystem = true | ) | const |
Obtain language tag as Locale.
As a convention, language tags that can not be expressed as "pure" css::lang::Locale content using Language and Country fields store "qlt" (ISO 639 reserved for local use) in the Language field and the entire BCP 47 language tag in the Variant field. The Country field contains the corresponding ISO 3166 country code if there is one, or otherwise is empty.
bResolveSystem | If TRUE, resolve an empty language tag denoting the system locale to the real locale used. If FALSE, return an empty Locale for such a tag. |
Definition at line 1720 of file languagetag.cxx.
References convertBcp47ToLocale(), convertLangToLocale(), maLocale, mbInitializedBcp47, mbInitializedLocale, mbSystemLocale, and syncVarsFromImpl().
Referenced by LanguageTagIcu::getIcuLocale(), and makeFallback().
|
static |
Search for an equal or for a similar locale in a list of possible ones where at least the language matches.
@descr First search for a locale that is equal to the reference locale.
If the reference locale could not be located, check for "similar" locales, in the same order as obtained by getFallbackStrings().
If no locale matches, rList.end() is returned.
rList | the vector of possible locales. |
rReference | the reference locale. |
Definition at line 2755 of file languagetag.cxx.
References getFallbackStrings(), i, and LanguageTag().
|
static |
Definition at line 706 of file languagetag.cxx.
References UNKNOWN.
Referenced by MsLangId::getScriptType(), MsLangId::isCJK(), and MsLangId::isRightToLeft().
OUString LanguageTag::getScript | ( | ) | const |
Get ISO 15924 script code, if not the default script according to BCP 47.
For default script an empty string is returned.
Always resolves an empty tag to the system locale.
Definition at line 1881 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::getScript(), LanguageTagImpl::maCachedScript, LanguageTagImpl::mbCachedScript, and syncFromImpl().
Referenced by getFallbackStrings(), getIsoLanguageScriptCountry(), getLanguageAndScript(), and MsLangId::isNonLatinWestern().
LanguageTag::ScriptType LanguageTag::getScriptType | ( | ) | const |
Returns the script type for this language, UNKNOWN if not set.
Definition at line 2023 of file languagetag.cxx.
References getImpl(), and LanguageTagImpl::getScriptType().
OUString LanguageTag::getVariants | ( | ) | const |
Get BCP 47 variant subtags, of the IANA Language Subtag Registry.
If there are multiple variant subtags they are separated by '-'.
This is NOT related to Locale.Variant!
Always resolves an empty tag to the system locale.
Definition at line 1945 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::getVariants(), LanguageTagImpl::maCachedVariants, LanguageTagImpl::mbCachedVariants, and syncFromImpl().
Referenced by getFallbackStrings().
bool LanguageTag::hasScript | ( | ) | const |
If language tag has a non-default script specified.
Definition at line 2009 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::hasScript(), and syncFromImpl().
Referenced by getFallbackStrings(), and MsLangId::isNonLatinWestern().
|
staticprivate |
Definition at line 1819 of file languagetag.cxx.
References SAL_WARN_IF.
Referenced by LanguageTagImpl::getCountry(), getIsoLanguageScriptCountry(), LanguageTagImpl::isIsoLocale(), and LanguageTagImpl::isIsoODF().
|
staticprivate |
Definition at line 1802 of file languagetag.cxx.
References SAL_WARN_IF.
Referenced by getIsoLanguageScriptCountry(), LanguageTagImpl::isIsoLocale(), and LanguageTagImpl::isIsoODF().
bool LanguageTag::isIsoLocale | ( | ) | const |
If language tag is a locale that can be expressed using only ISO 639 language codes and ISO 3166 country codes, thus is convertible to a conforming Locale struct without using extension mechanisms.
Note that an empty language tag or empty Locale::Language field or LanguageType LANGUAGE_SYSTEM could be treated as a valid ISO locale in some context, but here is not. If you want that ask for aTag.isSystemLocale() || aTag.isIsoLocale()
Always resolves an empty tag to the system locale.
Definition at line 2074 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::isIsoLocale(), and syncFromImpl().
Referenced by getFallbackStrings(), getGlibcLocaleString(), and LanguageTagIcu::getIcuLocale().
bool LanguageTag::isIsoODF | ( | ) | const |
If language tag is a locale that can be expressed using only ISO 639 language codes and ISO 15924 script codes and ISO 3166 country codes, thus can be stored in an ODF document using only fo:language, fo:script and fo:country attributes.
If this is FALSE, the locale must be stored as a <*:rfc-language-tag> element.
Always resolves an empty tag to the system locale.
Definition at line 2109 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::isIsoODF(), and syncFromImpl().
Referenced by getIsoLanguageScriptCountry().
|
staticprivate |
Definition at line 1832 of file languagetag.cxx.
References SAL_WARN_IF.
Referenced by getIsoLanguageScriptCountry(), and LanguageTagImpl::isIsoODF().
|
static |
If nLang is a generated on-the-fly LangID.
Definition at line 152 of file languagetag.cxx.
References MsLangId::getPrimaryLanguage(), MsLangId::getSubLanguage(), LANGUAGE_ON_THE_FLY_END, LANGUAGE_ON_THE_FLY_START, LANGUAGE_ON_THE_FLY_SUB_END, and LANGUAGE_ON_THE_FLY_SUB_START.
Referenced by MsLangId::getScriptType(), MsLangId::isCJK(), MsLangId::isRightToLeft(), and lcl_isKnownOnTheFlyID().
|
inline |
If this tag was constructed as an empty tag denoting the system locale.
Definition at line 267 of file languagetag.hxx.
References LanguageTagImpl::mbSystemLocale.
Referenced by equals(), and operator==().
bool LanguageTag::isValidBcp47 | ( | ) | const |
If this is a valid BCP 47 language tag.
Always resolves an empty tag to the system locale.
@seealso static bool isValidBcp47(const OUString&)
Definition at line 2129 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::isValidBcp47(), and syncFromImpl().
|
static |
If rString represents a valid BCP 47 language tag.
Never resolves an empty tag to the system locale, in fact an empty string is invalid here. Does not create an instance to be registered with a conversion to Locale or LanguageType.
o_pCanonicalized | If given and rString is a valid BCP 47 language tag, the canonicalized form is assigned, which may differ from the original string even if that was a valid tag. If rString is not a valid tag, nothing is assigned. |
ePrivateUse | If PrivateUse::DISALLOW, valid tags according to BCP 47 but reserved for private use, like 'x-...', are not allowed and FALSE is returned in this case. |
Definition at line 2931 of file languagetag.cxx.
References I18NLANGTAG_QLT_ASCII, lt_tag_parse_disabled, OUStringToOString(), SAL_INFO, and SAL_WARN_IF.
LanguageTag & LanguageTag::makeFallback | ( | ) |
Fall back to a known locale.
If the current tag does not represent a known (by us) locale, fall back to the most likely locale possible known. If the current tag is known, no change occurs.
Definition at line 2137 of file languagetag.cxx.
References getFallbackStrings(), getLocale(), LanguageTag(), MsLangId::Conversion::lookupFallbackLocale(), mbIsFallback, reset(), and SAL_INFO.
Referenced by getPlatformSystemLanguageImpl().
bool LanguageTag::operator!= | ( | const LanguageTag & | rLanguageTag | ) | const |
Test inequality of two LanguageTag.
Does NOT resolve system, i.e. if the system locale is en-US LanguageTag("")!=LanguageTag("en-US") returns true! Use !equals(,..) instead if system locales shall be resolved.
Definition at line 2434 of file languagetag.cxx.
References operator==().
bool LanguageTag::operator< | ( | const LanguageTag & | rLanguageTag | ) | const |
Test this LanguageTag less than that LanguageTag.
For sorted containers. Does NOT resolve system.
Definition at line 2440 of file languagetag.cxx.
References getBcp47().
|
default |
References getLocale().
|
default |
bool LanguageTag::operator== | ( | const LanguageTag & | rLanguageTag | ) | const |
Test equality of two LanguageTag.
Does NOT resolve system, i.e. if the system locale is en-US LanguageTag("")==LanguageTag("en-US") returns false! Use equals(...) instead if system locales shall be resolved.
Definition at line 2417 of file languagetag.cxx.
References getBcp47(), isSystemLocale(), mbInitializedLangID, and mnLangID.
Referenced by equals(), and operator!=().
|
private |
Definition at line 751 of file languagetag.cxx.
References MsLangId::Conversion::convertLanguageToLocale(), MsLangId::Conversion::convertLocaleToLanguage(), LanguageTagImpl::convertToBcp47(), MsLangId::getRealLanguage(), LANGUAGE_DONTKNOW, LANGUAGE_SYSTEM, lcl_isKnownOnTheFlyID(), maBcp47, maLocale, mbInitializedBcp47, mbInitializedLangID, mbInitializedLocale, mbSystemLocale, mnLangID, SAL_INFO, SAL_WARN, and SAL_WARN_IF.
Referenced by getImpl(), setConfiguredSystemLanguage(), and syncFromImpl().
LanguageTag & LanguageTag::reset | ( | const css::lang::Locale & | rLocale | ) |
Reset with Locale.
Definition at line 1065 of file languagetag.cxx.
References handleVendorVariant(), maLocale, mbInitializedLocale, mbSystemLocale, and resetVars().
LanguageTag & LanguageTag::reset | ( | const OUString & | rBcp47LanguageTag | ) |
Reset with existing BCP 47 language tag string.
See ctor.
Definition at line 1054 of file languagetag.cxx.
References maBcp47, mbInitializedBcp47, mbSystemLocale, and resetVars().
Referenced by makeFallback().
LanguageTag & LanguageTag::reset | ( | LanguageType | nLanguage | ) |
Reset with LanguageType MS-LangID.
Definition at line 1076 of file languagetag.cxx.
References LANGUAGE_SYSTEM, mbInitializedLangID, mbSystemLocale, mnLangID, and resetVars().
|
private |
Definition at line 1040 of file languagetag.cxx.
References LANGUAGE_SYSTEM, maBcp47, maLocale, mbInitializedBcp47, mbInitializedLangID, mbInitializedLocale, mbIsFallback, mbSystemLocale, mnLangID, and mpImpl.
Referenced by reset().
|
static |
@ATTENTION: ONLY to be called by the application's configuration!
Definition at line 718 of file languagetag.cxx.
References LANGUAGE_DONTKNOW, LANGUAGE_SYSTEM, registerImpl(), SAL_INFO, SAL_WARN, and MsLangId::LanguageTagAccess::setConfiguredSystemLanguage().
void LanguageTag::setScriptType | ( | LanguageTag::ScriptType | st | ) |
Sets the script type for this language.
Definition at line 2036 of file languagetag.cxx.
References getImpl(), and LanguageTagImpl::setScriptType().
|
private |
Canonicalize if not yet done and synchronize initialized conversions.
Definition at line 1344 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::synCanonicalize(), and syncFromImpl().
Referenced by getLanguageType().
|
private |
Definition at line 1304 of file languagetag.cxx.
References getImpl(), LanguageTagImpl::maBcp47, maBcp47, mbInitializedBcp47, mbInitializedLangID, LanguageTagImpl::mnLangID, mnLangID, mpImpl, registerImpl(), SAL_INFO_IF, and syncVarsFromRawImpl().
Referenced by convertBcp47ToLang(), convertBcp47ToLocale(), convertLangToLocale(), convertLocaleToLang(), getBcp47(), getCountry(), getLanguage(), getScript(), getVariants(), hasScript(), isIsoLocale(), isIsoODF(), isValidBcp47(), LanguageTag(), and synCanonicalize().
|
private |
Definition at line 1318 of file languagetag.cxx.
References getImpl(), mpImpl, and syncVarsFromRawImpl().
Referenced by getBcp47(), getLanguageType(), and getLocale().
|
private |
Definition at line 1327 of file languagetag.cxx.
References LanguageTagImpl::maBcp47, maBcp47, LanguageTagImpl::maLocale, maLocale, LanguageTagImpl::mbInitializedBcp47, mbInitializedBcp47, LanguageTagImpl::mbInitializedLangID, mbInitializedLangID, LanguageTagImpl::mbInitializedLocale, mbInitializedLocale, LanguageTagImpl::mnLangID, mnLangID, and mpImpl.
Referenced by getImpl(), syncFromImpl(), and syncVarsFromImpl().
|
friend |
Definition at line 54 of file languagetag.hxx.
|
mutableprivate |
Definition at line 562 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getBcp47(), getFallbackStrings(), LanguageTag(), registerImpl(), reset(), resetVars(), syncFromImpl(), and syncVarsFromRawImpl().
|
mutableprivate |
Definition at line 561 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getLocale(), LanguageTag(), registerImpl(), reset(), resetVars(), and syncVarsFromRawImpl().
|
mutableprivate |
Definition at line 566 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getBcp47(), getLanguageType(), getLocale(), LanguageTag(), registerImpl(), reset(), resetVars(), syncFromImpl(), and syncVarsFromRawImpl().
|
mutableprivate |
Definition at line 568 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getLanguageType(), operator==(), registerImpl(), reset(), resetVars(), syncFromImpl(), and syncVarsFromRawImpl().
|
mutableprivate |
Definition at line 567 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getLocale(), LanguageTag(), registerImpl(), reset(), resetVars(), and syncVarsFromRawImpl().
|
private |
Definition at line 569 of file languagetag.hxx.
Referenced by makeFallback(), and resetVars().
|
private |
Definition at line 565 of file languagetag.hxx.
Referenced by getBcp47(), getLanguageType(), getLocale(), LanguageTag(), registerImpl(), reset(), and resetVars().
|
mutableprivate |
Definition at line 563 of file languagetag.hxx.
Referenced by convertFromRtlLocale(), getLanguageType(), operator==(), registerImpl(), reset(), resetVars(), syncFromImpl(), and syncVarsFromRawImpl().
|
mutableprivate |
Definition at line 564 of file languagetag.hxx.
Referenced by getImpl(), resetVars(), syncFromImpl(), syncVarsFromImpl(), and syncVarsFromRawImpl().