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. |
110 \return true if operation was successful |
113 \return true if operation was successful |
111 */ |
114 */ |
112 bool setLocale( int language ) |
115 bool setLocale( int language ) |
113 { |
116 { |
114 TExtendedLocale dummy; |
117 TExtendedLocale dummy; |
|
118 dummy.LoadSystemSettings(); |
115 QString no; |
119 QString no; |
116 no = QString( "%1" ).arg( language, 2, 10, QLatin1Char( '0' ) ); |
120 no = QString( "%1" ).arg( language, 2, 10, QLatin1Char( '0' ) ); |
117 QString name = QString( "elocl." ).append( no ); |
121 QString name = QString( "elocl." ).append( no ); |
118 TPtrC nameptr(name.utf16()); |
122 TPtrC nameptr(name.utf16()); |
119 |
123 |
132 \brief Returns names and identifiers of supported languages in a phone. |
136 \brief Returns names and identifiers of supported languages in a phone. |
133 |
137 |
134 Language names are localized according the language's native presentation. |
138 Language names are localized according the language's native presentation. |
135 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. |
136 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. |
137 |
141 |
138 \return localized names and integer identifiers of languages supported in a device |
142 \attention Symbian specific API |
|
143 |
|
144 \deprecated HbLanguageUtil::supportedLanguages() |
|
145 is deprecated. Please use HbLocaleUtil::supportedLanguages() instead. |
|
146 |
|
147 \return Symbian - localized names and integer identifiers of languages supported in a device |
|
148 \return other platforms - empty QHash |
139 */ |
149 */ |
140 QHash<int, QString> HbLanguageUtil::supportedLanguages() |
150 QHash<int, QString> HbLanguageUtil::supportedLanguages() |
141 { |
151 { |
142 #if defined(Q_OS_SYMBIAN) |
152 #if defined(Q_OS_SYMBIAN) |
143 QHash<int, QString> languages; |
153 QHash<int, QString> languages; |
144 |
154 |
145 QTranslator translator; |
155 QTranslator translator; |
146 if (!translator.load(TRANSLATOR_PATH)) { |
156 QString path = "c:"; |
147 return languages; |
157 path += QString(TRANSLATOR_PATH); |
|
158 if (!translator.load(path)) { |
|
159 path = "z:"; |
|
160 path += QString(TRANSLATOR_PATH); |
|
161 if (!translator.load(path)) { |
|
162 return languages; |
|
163 } |
148 } |
164 } |
|
165 |
149 QCoreApplication::installTranslator(&translator); |
166 QCoreApplication::installTranslator(&translator); |
150 QHash<int, QString> hashLanguageNames = readLanguageList(); |
167 QHash<int, QString> hashLanguageNames = readLanguageList(); |
151 |
168 |
152 CArrayFixFlat<TInt>* systemEpocLanguageCodes = 0; |
169 CArrayFixFlat<TInt>* systemEpocLanguageCodes = 0; |
153 TInt error = SysLangUtil::GetInstalledLanguages( systemEpocLanguageCodes ); |
170 TInt error = SysLangUtil::GetInstalledLanguages( systemEpocLanguageCodes ); |
180 |
197 |
181 Language names are localized according the language's native presentation. |
198 Language names are localized according the language's native presentation. |
182 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. |
183 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. |
184 |
201 |
185 \return localized names and integer identifiers of known languages |
202 \attention Symbian specific API |
|
203 |
|
204 \deprecated HbLanguageUtil::allLanguages() |
|
205 is deprecated. |
|
206 |
|
207 \return Symbian - localized names and integer identifiers of known languages |
|
208 \return other platforms - empty QHash |
186 */ |
209 */ |
187 QHash<int, QString> HbLanguageUtil::allLanguages() |
210 QHash<int, QString> HbLanguageUtil::allLanguages() |
188 { |
211 { |
189 #if defined(Q_OS_SYMBIAN) |
212 #if defined(Q_OS_SYMBIAN) |
190 QHash<int, QString> langs; |
213 QHash<int, QString> langs; |
191 |
214 |
192 QTranslator translator; |
215 QTranslator translator; |
193 if (!translator.load(TRANSLATOR_PATH)) { |
216 QString path = "c:"; |
194 return langs; |
217 path += QString(TRANSLATOR_PATH); |
|
218 if (!translator.load(path)) { |
|
219 path = "z:"; |
|
220 path += QString(TRANSLATOR_PATH); |
|
221 if (!translator.load(path)) { |
|
222 return langs; |
|
223 } |
195 } |
224 } |
|
225 |
196 QCoreApplication::installTranslator(&translator); |
226 QCoreApplication::installTranslator(&translator); |
197 |
227 |
198 QHash<int, QString> languageNameList = readLanguageList(); |
228 QHash<int, QString> languageNameList = readLanguageList(); |
199 QHashIterator<int, QString> i(languageNameList); |
229 QHashIterator<int, QString> i(languageNameList); |
200 while (i.hasNext()) { |
230 while (i.hasNext()) { |
215 #endif |
245 #endif |
216 } |
246 } |
217 |
247 |
218 /*! |
248 /*! |
219 \brief Changes the device system language. |
249 \brief Changes the device system language. |
220 |
250 |
221 \param identifier of language to set active |
251 \attention Symbian specific API |
222 \return true if language change was successful |
252 |
|
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 |
|
257 \return true for Symbian if succesfull and false for other platforms |
223 */ |
258 */ |
224 bool HbLanguageUtil::changeLanguage( int language ) |
259 bool HbLanguageUtil::changeLanguage( int language ) |
225 { |
260 { |
226 #if defined(Q_OS_SYMBIAN) |
261 #if defined(Q_OS_SYMBIAN) |
227 if ( !HbFeatureManager::instance()->featureStatus(HbFeatureManager::LanguageSwitch) ) { |
262 if ( !HbFeatureManager::instance()->featureStatus(HbFeatureManager::LanguageSwitch) ) { |
260 } |
295 } |
261 |
296 |
262 /*! |
297 /*! |
263 \brief Returns ID of current language. |
298 \brief Returns ID of current language. |
264 |
299 |
265 \return identifier of current system language |
300 \attention Symbian specific API |
|
301 |
|
302 \deprecated HbLanguageUtil::currentLanguage() |
|
303 is deprecated. Please use HbLocaleUtil::currentLanguage() instead. |
|
304 |
|
305 \return identifier of current system language for Symbian and '0' for other platforms |
266 */ |
306 */ |
267 int HbLanguageUtil::currentLanguage() |
307 int HbLanguageUtil::currentLanguage() |
268 { |
308 { |
269 #if defined(Q_OS_SYMBIAN) |
309 #if defined(Q_OS_SYMBIAN) |
270 TLanguage l = User::Language(); |
310 TLanguage l = User::Language(); |