summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-03-13 16:35:46 +0100
committerEike Rathke <erack@redhat.com>2013-03-13 16:48:12 +0100
commitfb26196ce64979ab6dc6c82c0fbdeedb126a3433 (patch)
treeac64c22c90d8ac98e9ae0346e39bbefb5e4ec119
parent6ecfbf153a7c11c63d208630ac6a27064058099d (diff)
added LanguageTag::equals(), fdo#62278 related
Change-Id: I6471f8eaa46d9203c75569436b233a09fe337910
-rw-r--r--i18npool/inc/i18npool/languagetag.hxx24
-rw-r--r--i18npool/source/languagetag/languagetag.cxx7
2 files changed, 29 insertions, 2 deletions
diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx
index ff8266d2de79..7dedc8f16bbc 100644
--- a/i18npool/inc/i18npool/languagetag.hxx
+++ b/i18npool/inc/i18npool/languagetag.hxx
@@ -236,10 +236,30 @@ public:
*/
::std::vector< OUString > getFallbackStrings() const;
- /* Test equality of two LangageTag. */
+ /** Test equality of two LanguageTag, possibly resolving system locale.
+
+ @param bResolveSystem
+ If TRUE, resolve empty language tags denoting the system
+ locale to the real locale used before comparing.
+ If FALSE, the behavior is identical to operator==(), system
+ locales are not resolved first.
+ */
+ bool equals( const LanguageTag & rLanguageTag, bool bResolveSystem = false ) 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(...,true) instead if system locales shall be resolved.
+ */
bool operator==( const LanguageTag & rLanguageTag ) const;
- /* Test inequality of two LangageTag. */
+ /** 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(,...true) instead if system locales shall be resolved.
+ */
bool operator!=( const LanguageTag & rLanguageTag ) const;
private:
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx
index c51096255a32..238627415400 100644
--- a/i18npool/source/languagetag/languagetag.cxx
+++ b/i18npool/source/languagetag/languagetag.cxx
@@ -1094,6 +1094,13 @@ LanguageTag & LanguageTag::makeFallback()
}
+bool LanguageTag::equals( const LanguageTag & rLanguageTag, bool bResolveSystem ) const
+{
+ // Compare full language tag strings.
+ return getBcp47( bResolveSystem) == rLanguageTag.getBcp47( bResolveSystem);
+}
+
+
bool LanguageTag::operator==( const LanguageTag & rLanguageTag ) const
{
// Compare full language tag strings but SYSTEM unresolved.