summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-06-14 15:13:21 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-06-14 15:55:49 +0900
commitc8b6d7c69aa6227d6f288349379c89f9a20fb48e (patch)
tree7bc90f9d310943740787ef09f0359a99a391fda6
parent52c08435887de74da64c77caee7adad0b67cf54a (diff)
downloadappcore-widget-c8b6d7c69aa6227d6f288349379c89f9a20fb48e.tar.gz
appcore-widget-c8b6d7c69aa6227d6f288349379c89f9a20fb48e.tar.bz2
appcore-widget-c8b6d7c69aa6227d6f288349379c89f9a20fb48e.zip
Change-Id: I7583298a629d57d3df27dccbc9ef8a1420b7021e Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rwxr-xr-xsrc/widget-i18n.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/widget-i18n.c b/src/widget-i18n.c
index 91804e2..c739dd8 100755
--- a/src/widget-i18n.c
+++ b/src/widget-i18n.c
@@ -31,6 +31,8 @@
#include "widget-log.h"
#include "widget-private.h"
+#define PATH_LOCALE "locale"
+
void _update_lang(void)
{
char *r;
@@ -80,10 +82,27 @@ void _update_region(void)
}
}
+static int __get_locale_resource_dir(char *locale_dir, int size)
+{
+ const char *res_path;
+
+ res_path = aul_get_app_resource_path();
+ if (res_path == NULL) {
+ _E("Failed to get resource path");
+ return -1;
+ }
+
+ snprintf(locale_dir, size, "%s" PATH_LOCALE, res_path);
+ if (access(locale_dir, R_OK) != 0)
+ return -1;
+
+ return 0;
+}
+
static int __set_i18n(const char *domain)
{
char *r;
- char dirname[PATH_MAX] = {0, };
+ char locale_dir[PATH_MAX];
char *lang;
if (domain == NULL) {
@@ -91,8 +110,8 @@ static int __set_i18n(const char *domain)
return -1;
}
- snprintf(dirname, PATH_MAX, "%s/res/locale", aul_get_app_root_path());
- _D("locale dir: %s", dirname);
+ __get_locale_resource_dir(locale_dir, sizeof(locale_dir));
+ _D("locale dir: %s", locale_dir);
r = setlocale(LC_ALL, "");
/* if locale is not set properly, try again to set as language base */
@@ -108,7 +127,7 @@ static int __set_i18n(const char *domain)
if (r == NULL)
_E("appcore: setlocale() error");
- r = bindtextdomain(domain, dirname);
+ r = bindtextdomain(domain, locale_dir);
if (r == NULL)
_E("appcore: bindtextdomain() error");