36 #include "../../ucx/string.h" |
36 #include "../../ucx/string.h" |
37 #include "../../ucx/buffer.h" |
37 #include "../../ucx/buffer.h" |
38 #include "../../ucx/properties.h" |
38 #include "../../ucx/properties.h" |
39 |
39 |
40 static UiProperties *application_properties; |
40 static UiProperties *application_properties; |
|
41 static UiProperties *language; |
41 |
42 |
42 char* ui_getappdir() { |
43 char* ui_getappdir() { |
43 if(ui_appname() == NULL) { |
44 if(ui_appname() == NULL) { |
44 return NULL; |
45 return NULL; |
45 } |
46 } |
170 char *v = ucx_map_cstr_get(application_properties, name); |
171 char *v = ucx_map_cstr_get(application_properties, name); |
171 if(!v) { |
172 if(!v) { |
172 ucx_map_cstr_put(application_properties, name, value); |
173 ucx_map_cstr_put(application_properties, name, value); |
173 } |
174 } |
174 } |
175 } |
|
176 |
|
177 |
|
178 |
|
179 #ifndef UI_COCOA |
|
180 |
|
181 void ui_load_locale(char *locale) { |
|
182 char *basedir = ui_get_locale_basedir(); |
|
183 } |
|
184 |
|
185 #endif |
|
186 |
|
187 void uic_load_language_file(char *path) { |
|
188 UcxMap *lang = ucx_map_new(256); |
|
189 |
|
190 printf("path: %s\n", path); |
|
191 FILE *file = fopen(path, "r"); |
|
192 if(!file) { |
|
193 printf("cannot open file: %s\n", path); |
|
194 free(path); |
|
195 return; |
|
196 } |
|
197 |
|
198 if(ucx_properties_load(lang, file)) { |
|
199 fprintf(stderr, "Ui Error: Cannot load locale.\n"); |
|
200 } |
|
201 |
|
202 fclose(file); |
|
203 |
|
204 ucx_map_rehash(lang); |
|
205 |
|
206 language = lang; |
|
207 } |
|
208 |
|
209 char* uistr(char *name) { |
|
210 if(!language) { |
|
211 return "missing string"; |
|
212 } |
|
213 char *value = ucx_map_cstr_get(language, name); |
|
214 if(!value) { |
|
215 return "missing string"; |
|
216 } else { |
|
217 return value; |
|
218 } |
|
219 } |