summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-12-18 16:45:29 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-18 16:48:34 +0900
commite20978054a2f690797813b9283bc88ef8827faff (patch)
tree13bd7bb16904e4419f763ac6fc26405838ed6b0e /src/lib/efreet
parenta32653784f16fa6b502ab59b6a477c3da8dd92ef (diff)
Efreet: support language, country and modifer on Windows
Summary: On Windows, the environment variables LANG, LC_ALL and LC_MESSAGES do not exist, so retrieve langage and country modifier directly from the systeM Test Plan: verify the value with some ptrinF Reviewers: jpeg Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3464
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/lib/efreet/efreet.c b/src/lib/efreet/efreet.c
index 91d093e775..091899f2b2 100644
--- a/src/lib/efreet/efreet.c
+++ b/src/lib/efreet/efreet.c
@@ -232,7 +232,8 @@ efreet_language_get(void)
232 * @internal 232 * @internal
233 * @return Returns no value 233 * @return Returns no value
234 * @brief Parses out the language, country and modifer setting from the 234 * @brief Parses out the language, country and modifer setting from the
235 * LC_MESSAGES environment variable 235 * LC_MESSAGES environment variable on UNIX. On Windows, retrieve them from
236 * the system.
236 */ 237 */
237static void 238static void
238efreet_parse_locale(void) 239efreet_parse_locale(void)
@@ -247,7 +248,7 @@ efreet_parse_locale(void)
247 248
248 if (efreet_parse_locale_setting("LC_MESSAGES")) 249 if (efreet_parse_locale_setting("LC_MESSAGES"))
249 return; 250 return;
250 251
251 efreet_language = eina_stringshare_add("C"); 252 efreet_language = eina_stringshare_add("C");
252} 253}
253 254
@@ -257,10 +258,41 @@ efreet_parse_locale(void)
257 * @return Returns 1 if we parsed something of @a env, 0 otherwise 258 * @return Returns 1 if we parsed something of @a env, 0 otherwise
258 * @brief Tries to parse the lang settings out of the given environment 259 * @brief Tries to parse the lang settings out of the given environment
259 * variable 260 * variable
261 *
262 * @note @a env is not used on Windows.
260 */ 263 */
261static int 264static int
262efreet_parse_locale_setting(const char *env) 265efreet_parse_locale_setting(const char *env)
263{ 266{
267#ifdef _WIN32
268 char buf_lang[18];
269 char buf[9];
270 int l1;
271 int l2;
272
273 l1 = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME,
274 buf, sizeof(buf));
275 if (!l1)
276 return 0;
277
278 efreet_lang = eina_stringshare_add(buf);
279 memcpy(buf_lang, buf, l1 - 1);
280 buf_lang[l1 - 1] = '_';
281
282 l2 = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME,
283 buf, sizeof(buf));
284 if (!l2)
285 return 0;
286
287 efreet_lang_country = eina_stringshare_add(buf);
288 memcpy(buf_lang + l1, buf, l2);
289
290 efreet_language = eina_stringshare_add(buf_lang);
291
292 return 1;
293
294 (void)env;
295#else
264 int found = 0; 296 int found = 0;
265 char *setting; 297 char *setting;
266 char *p; 298 char *p;
@@ -303,6 +335,7 @@ efreet_parse_locale_setting(const char *env)
303 if (found) 335 if (found)
304 efreet_language = eina_stringshare_add(getenv(env)); 336 efreet_language = eina_stringshare_add(getenv(env));
305 return found; 337 return found;
338#endif
306} 339}
307 340
308/** 341/**