2 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <linux/limits.h>
31 #include "widget-log.h"
32 #include "widget-private.h"
34 void _update_lang(void)
37 char *lang = vconf_get_str(VCONFKEY_LANGSET);
39 setenv("LANG", lang, 1);
40 setenv("LC_MESSAGES", lang, 1);
42 r = setlocale(LC_ALL, "");
44 r = setlocale(LC_ALL, lang);
46 _D("*****appcore setlocale=%s\n", r);
50 _E("failed to get current language for set lang env");
54 void _update_region(void)
59 region = vconf_get_str(VCONFKEY_REGIONFORMAT);
61 setenv("LC_CTYPE", region, 1);
62 setenv("LC_NUMERIC", region, 1);
63 setenv("LC_TIME", region, 1);
64 setenv("LC_COLLATE", region, 1);
65 setenv("LC_MONETARY", region, 1);
66 setenv("LC_PAPER", region, 1);
67 setenv("LC_NAME", region, 1);
68 setenv("LC_ADDRESS", region, 1);
69 setenv("LC_TELEPHONE", region, 1);
70 setenv("LC_MEASUREMENT", region, 1);
71 setenv("LC_IDENTIFICATION", region, 1);
73 r = setlocale(LC_ALL, "");
75 _D("*****appcore setlocale=%s\n", r);
79 _E("failed to get current region format for set region env");
83 static int __set_i18n(const char *domain)
86 char dirname[PATH_MAX] = {0, };
94 snprintf(dirname, PATH_MAX, "%s/res/locale", aul_get_app_root_path());
95 _D("locale dir: %s", dirname);
97 r = setlocale(LC_ALL, "");
98 /* if locale is not set properly, try again to set as language base */
100 lang = vconf_get_str(VCONFKEY_LANGSET);
101 r = setlocale(LC_ALL, lang);
103 _D("*****appcore setlocale=%s\n", r);
109 _E("appcore: setlocale() error");
111 r = bindtextdomain(domain, dirname);
113 _E("appcore: bindtextdomain() error");
115 r = textdomain(domain);
117 _E("appcore: textdomain() error");
122 int _set_i18n(const char *domainname)
127 return __set_i18n(domainname);