#include "widget-log.h"
#include "widget-private.h"
+#define PATH_LOCALE "locale"
+
void _update_lang(void)
{
char *r;
}
}
+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) {
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 */
if (r == NULL)
_E("appcore: setlocale() error");
- r = bindtextdomain(domain, dirname);
+ r = bindtextdomain(domain, locale_dir);
if (r == NULL)
_E("appcore: bindtextdomain() error");