41 #include <syslangutil.h> |
41 #include <syslangutil.h> |
42 #include <CommonEngineDomainCRKeys.h> //Ui language |
42 #include <CommonEngineDomainCRKeys.h> //Ui language |
43 #endif // Q_OS_SYMBIAN |
43 #endif // Q_OS_SYMBIAN |
44 |
44 |
45 #include "hblanguageutil.h" |
45 #include "hblanguageutil.h" |
46 #include "hbfeaturemanager_p.h" |
46 #include "hbfeaturemanager_r.h" |
47 |
47 |
48 #if defined(Q_OS_SYMBIAN) |
48 #if defined(Q_OS_SYMBIAN) |
49 #define LANGUAGE_LIST_FILE "/resource/hbi18n/translations/language_list.txt" |
49 #define LANGUAGE_LIST_FILE "/resource/hbi18n/translations/language_list.txt" |
50 #define LANGUAGE_ID_PREFIX "language_" |
50 #define LANGUAGE_ID_PREFIX "language_" |
51 #define TRANSLATOR_PATH "/resource/hbi18n/translations/languages" |
51 #define TRANSLATOR_PATH "/resource/hbi18n/translations/languages_OLD" |
52 #endif // Q_OS_SYMBIAN |
52 #endif // Q_OS_SYMBIAN |
53 |
53 |
54 /*! |
54 /*! |
55 @beta |
55 @beta |
56 @hbcore |
56 @hbcore |
57 \class HbLanguageUtil |
57 \class HbLanguageUtil |
58 \brief HbLanguageUtil provides functions for quering supported languages and switching the system language. |
58 \brief HbLanguageUtil provides functions for quering supported languages and switching the system language. |
|
59 |
|
60 \deprecated HbLanguageUtil class |
|
61 is deprecated. Please use HbLocaleUtil class instead. |
59 */ |
62 */ |
60 |
63 |
61 #if defined(Q_OS_SYMBIAN) |
64 #if defined(Q_OS_SYMBIAN) |
62 /*! |
65 /*! |
63 \brief Returns identifiers and localized names of all known languages. |
66 \brief Returns identifiers and localized names of all known languages. |
111 */ |
114 */ |
112 bool setLocale( int language ) |
115 bool setLocale( int language ) |
113 { |
116 { |
114 TExtendedLocale dummy; |
117 TExtendedLocale dummy; |
115 dummy.LoadSystemSettings(); |
118 dummy.LoadSystemSettings(); |
116 |
|
117 // Try to load new locale model dll |
|
118 QString no; |
119 QString no; |
119 if ( language < 10 ) { |
120 no = QString( "%1" ).arg( language, 2, 10, QLatin1Char( '0' ) ); |
120 no = QString( "00%1" ).arg(language); |
121 QString name = QString( "elocl." ).append( no ); |
121 } else if ( language < 100 ) { |
|
122 no = QString( "0%1" ).arg(language); |
|
123 } else { |
|
124 no = QString( "%1" ).arg(language); |
|
125 } |
|
126 |
|
127 QString name = QString("elocl_lan.").append(no); |
|
128 TPtrC nameptr(name.utf16()); |
122 TPtrC nameptr(name.utf16()); |
129 |
123 |
130 TInt err = dummy.LoadLocaleAspect(nameptr); |
124 TInt err = dummy.LoadLocale( nameptr ); |
131 if( err != KErrNone ) { |
125 if( err != KErrNone ) |
132 // Loading new locale model dll fails |
126 return false; |
133 // Try to load old locale model dll |
|
134 no = QString("%1").arg(language, 2, 10, QLatin1Char( '0' )); |
|
135 QString name2 = QString("elocl.").append(no); |
|
136 TPtrC nameptr2(name2.utf16()); |
|
137 |
|
138 TInt err2 = dummy.LoadLocale(nameptr2); |
|
139 if ( err2 != KErrNone ) { |
|
140 return false; |
|
141 } |
|
142 } |
|
143 |
|
144 dummy.SaveSystemSettings(); |
127 dummy.SaveSystemSettings(); |
145 // cause localeprivate update on next qlocale object( glp->m_language_id = 0 ) |
128 // cause localeprivate update on next qlocale object( glp->m_language_id = 0 ) |
146 QSystemLocale dummy2; |
129 QSystemLocale dummy2; |
147 return true; |
130 return true; |
148 } |
131 } |
156 Language ID's returned by this functions may be used as language parameter for changeLanguage(int language) function. |
139 Language ID's returned by this functions may be used as language parameter for changeLanguage(int language) function. |
157 Language IDs and names are OS specific and may vary across the platforms and releases. |
140 Language IDs and names are OS specific and may vary across the platforms and releases. |
158 |
141 |
159 \attention Symbian specific API |
142 \attention Symbian specific API |
160 |
143 |
|
144 \deprecated HbLanguageUtil::supportedLanguages() |
|
145 is deprecated. Please use HbLocaleUtil::supportedLanguages() instead. |
|
146 |
161 \return Symbian - localized names and integer identifiers of languages supported in a device |
147 \return Symbian - localized names and integer identifiers of languages supported in a device |
162 \return other platforms - empty QHash |
148 \return other platforms - empty QHash |
163 */ |
149 */ |
164 QHash<int, QString> HbLanguageUtil::supportedLanguages() |
150 QHash<int, QString> HbLanguageUtil::supportedLanguages() |
165 { |
151 { |
213 Language ID's returned by this functions may be used as language parameter for changeLanguage(int language) function. |
199 Language ID's returned by this functions may be used as language parameter for changeLanguage(int language) function. |
214 Language IDs and names are OS specific and may vary across the platforms and releases. |
200 Language IDs and names are OS specific and may vary across the platforms and releases. |
215 |
201 |
216 \attention Symbian specific API |
202 \attention Symbian specific API |
217 |
203 |
|
204 \deprecated HbLanguageUtil::allLanguages() |
|
205 is deprecated. |
|
206 |
218 \return Symbian - localized names and integer identifiers of known languages |
207 \return Symbian - localized names and integer identifiers of known languages |
219 \return other platforms - empty QHash |
208 \return other platforms - empty QHash |
220 */ |
209 */ |
221 QHash<int, QString> HbLanguageUtil::allLanguages() |
210 QHash<int, QString> HbLanguageUtil::allLanguages() |
222 { |
211 { |
259 /*! |
248 /*! |
260 \brief Changes the device system language. |
249 \brief Changes the device system language. |
261 |
250 |
262 \attention Symbian specific API |
251 \attention Symbian specific API |
263 |
252 |
264 \param identifier of language to set active |
253 \deprecated HbLanguageUtil::changeLanguage( int language ) |
|
254 is deprecated. Please use HbLocaleUtil::changeLanguage( const QString &language ) instead. |
|
255 |
|
256 \param language identifier of language to set active |
265 \return true for Symbian if succesfull and false for other platforms |
257 \return true for Symbian if succesfull and false for other platforms |
266 */ |
258 */ |
267 bool HbLanguageUtil::changeLanguage( int language ) |
259 bool HbLanguageUtil::changeLanguage( int language ) |
268 { |
260 { |
269 #if defined(Q_OS_SYMBIAN) |
261 #if defined(Q_OS_SYMBIAN) |
305 /*! |
297 /*! |
306 \brief Returns ID of current language. |
298 \brief Returns ID of current language. |
307 |
299 |
308 \attention Symbian specific API |
300 \attention Symbian specific API |
309 |
301 |
|
302 \deprecated HbLanguageUtil::currentLanguage() |
|
303 is deprecated. Please use HbLocaleUtil::currentLanguage() instead. |
|
304 |
310 \return identifier of current system language for Symbian and '0' for other platforms |
305 \return identifier of current system language for Symbian and '0' for other platforms |
311 */ |
306 */ |
312 int HbLanguageUtil::currentLanguage() |
307 int HbLanguageUtil::currentLanguage() |
313 { |
308 { |
314 #if defined(Q_OS_SYMBIAN) |
309 #if defined(Q_OS_SYMBIAN) |