4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <gconf/gconf-client.h>
30 #include "mm_file_debug.h"
31 #include "mm_file_utils.h"
33 /* This macro is the same with global-gconf.h */
34 #define MMFILE_LANGUAGETYPE_REPOSITORY "/Apps/Settings/language_type"
36 MMFILE_LANGUAGE_ENGLISH = 0x00, /**<Language - English*/
37 MMFILE_LANGUAGE_GERMAN, /**<Language - German*/
38 MMFILE_LANGUAGE_FRENCH, /**<Language - French*/
39 MMFILE_LANGUAGE_ITALIAN, /**<Language - Italian*/
40 MMFILE_LANGUAGE_DUTCH, /**<Language - Dutch*/
41 MMFILE_LANGUAGE_SPANISH, /**<Language - Spanish*/
42 MMFILE_LANGUAGE_GREEK, /**<Language - Greek*/
43 MMFILE_LANGUAGE_PORTUGUESE, /**<Language - Portuguese*/
44 MMFILE_LANGUAGE_TURKISH, /**<Language - Turkish*/
45 MMFILE_LANGUAGE_JAPAN_CP932, /**<Language - Japanease for CP932*/
46 MMFILE_LANGUAGE_SIM_CHINA, /**<Language - Simplified Chinese*/
47 MMFILE_LANGUAGE_TRA_CHINA, /**<Language - Traditional Chinese*/
48 MMFILE_LANGUAGE_JAPAN, /**<Language - Japanease*/
50 MMFILE_LANGUAGE_BULGARIAN, /**<Language - Bulgarian*/
51 MMFILE_LANGUAGE_ARABIC, /**<Language - Arabic*/
54 } eMMFileSettingPhoneLanguage;
56 const char *MMFILE_LOCALE_TABLE[MMFILE_LANGUAGE_MAX] = {
57 "EUC-KR", /* Temporally - Language - English */
58 "ISO8859-1", /* Language - German */
59 "ISO8859-1", /* Language - French */
60 "ISO8859-1", /* Language - Italian */
61 "ISO8859-1", /* Temporally - Language - Dutch */
62 "ISO8859-1", /* Language - Spanish */
63 "ISO8859-7", /* Language - Greek */
64 "ISO8859-1", /* Language - Portuguese */
65 "ISO8859-3", /* Language - Turkish */
66 "CP932", /* Language - Japan*/
67 "GBK", /* Language - Simplified Chinese */
68 "BIG5", /* Language - Traditional Chinese */
69 "SHIFT_JIS" /* Language - Japanease */
71 /* Language - Bulgarian */
72 /* Language - Arabic */
77 static int _MMFileUtilGetLocaleindex()
79 int index = MMFILE_LANGUAGE_ENGLISH;
82 const char *china_prefix = "zh";
83 const char *eng_prefix = "en";
85 const char *china_lang = "zh_CN";
86 /*const char *hongkong_lang = "zh_HK";*/
87 /*const char *taiwan_lang = "zh_TW";*/
88 const char *jpn_lang = "ja_JP";
90 lang = vconf_get_str(VCONFKEY_LANGSET);
93 if (strncmp(lang, china_prefix, strlen(china_prefix)) == 0) {
94 /* This case is selected language is china */
95 if (strncmp(lang, china_lang, strlen(china_lang)) == 0) {
96 debug_msg(DEBUG, "[%s]character set is simplified chinese", lang);
97 index = MMFILE_LANGUAGE_SIM_CHINA;
99 debug_msg(DEBUG, "[%s]character set is traditional chinese", lang);
100 index = MMFILE_LANGUAGE_TRA_CHINA;
102 } else if (strncmp(lang, eng_prefix, strlen(eng_prefix)) == 0) {
103 /* This case is selected language is engilish
104 In case of engilish, the character set is related with region of target binary */
105 debug_msg(DEBUG, "[%s]character set is engilish", lang);
106 index = MMFILE_LANGUAGE_ENGLISH;
107 } else if (strncmp(lang, jpn_lang, strlen(jpn_lang)) == 0) {
108 /* This case is selected language is japanease */
109 debug_msg(DEBUG, "[%s]character set is japanease", lang);
110 index = MMFILE_LANGUAGE_JAPAN;
112 debug_error(DEBUG, "use default character set");
113 index = MMFILE_LANGUAGE_ENGLISH;
116 debug_error(DEBUG, "language value is NULL, use default character set");
117 index = MMFILE_LANGUAGE_ENGLISH;
129 char *MMFileUtilGetLocale(int *error)
133 index = _MMFileUtilGetLocaleindex();
135 if (index < 0 || index >= MMFILE_LANGUAGE_MAX) {
136 debug_error(DEBUG, "invalid index\n");
137 err = MMFILE_UTIL_FAIL;
141 err = MMFILE_UTIL_SUCCESS;
146 return (char *)MMFILE_LOCALE_TABLE[index];