diff options
author | Eike Rathke <erack@redhat.com> | 2013-09-05 10:07:32 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-09-05 14:57:25 +0200 |
commit | acd09adae4c53cfb6b70ff2146f97043ce1487dd (patch) | |
tree | e981da9253ea8dfabea59b402fa719841f877fa8 /i18npool | |
parent | 748bf45544a31b7bd6217d046009e272d11aa310 (diff) |
added getFirstLocaleServiceName() and getFallbackLocaleServiceNames()
Change-Id: I35d3c5baeb5501feacdfa146f5b7f4e4f1bba876
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/localedata.hxx | 7 | ||||
-rw-r--r-- | i18npool/source/localedata/localedata.cxx | 33 |
2 files changed, 40 insertions, 0 deletions
diff --git a/i18npool/inc/localedata.hxx b/i18npool/inc/localedata.hxx index dbab5ca6d32e..43fcdd715ac5 100644 --- a/i18npool/inc/localedata.hxx +++ b/i18npool/inc/localedata.hxx @@ -75,6 +75,13 @@ public: static com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > downcastCalendarItems( const com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > & rCi ); static com::sun::star::i18n::Calendar downcastCalendar( const com::sun::star::i18n::Calendar2 & rC ); + /** Generates a <Language>_<Country> or <Variant> (if Language=="qlt") + string suitable as part of service name with all '-' replaced by '_' */ + static OUString getFirstLocaleServiceName( const com::sun::star::lang::Locale & rLocale ); + /** Generates fallback strings suitable as parts of service names, + excluding the one obtained via getFirstLocaleServiceName() */ + static ::std::vector< OUString > getFallbackLocaleServiceNames( const com::sun::star::lang::Locale & rLocale ); + virtual LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); virtual LocaleDataItem SAL_CALL getLocaleItem( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); virtual com::sun::star::uno::Sequence< Calendar2 > SAL_CALL getAllCalendars2( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index c980d2af8faf..2b5ed9e93a0e 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -20,6 +20,7 @@ #include <localedata.hxx> #include <i18nlangtag/mslangid.hxx> +#include <i18nlangtag/languagetag.hxx> #include <rtl/ustrbuf.hxx> #include <string.h> #include <stdio.h> @@ -1656,4 +1657,36 @@ LocaleData::getSupportedServiceNames() throw( RuntimeException ) return aRet; } +// static +OUString LocaleData::getFirstLocaleServiceName( const com::sun::star::lang::Locale & rLocale ) +{ + if (rLocale.Language == I18NLANGTAG_QLT) + return rLocale.Variant.replaceAll( "-", "_"); + else if (!rLocale.Country.isEmpty()) + return rLocale.Language + "_" + rLocale.Country; + else + return rLocale.Language; +} + +// static +::std::vector< OUString > LocaleData::getFallbackLocaleServiceNames( const com::sun::star::lang::Locale & rLocale ) +{ + ::std::vector< OUString > aVec; + if (rLocale.Language == I18NLANGTAG_QLT) + { + aVec = LanguageTag( rLocale).getFallbackStrings(); + aVec.erase( aVec.begin()); + for (::std::vector< OUString >::iterator it(aVec.begin()); it != aVec.end(); ++it) + { + *it = (*it).replaceAll( "-", "_"); + } + } + else if (!rLocale.Country.isEmpty()) + { + aVec.push_back( rLocale.Language); + } + // else nothing, language-only was the first + return aVec; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |