ui/common/properties.c

changeset 29
c96169444d88
parent 24
06bceda81a03
child 30
34513f76d5a8
--- a/ui/common/properties.c	Sun Apr 06 13:21:37 2014 +0200
+++ b/ui/common/properties.c	Thu Apr 10 11:37:41 2014 +0200
@@ -38,6 +38,7 @@
 #include "../../ucx/properties.h"
 
 static UiProperties *application_properties;
+static UiProperties *language;
 
 char* ui_getappdir() {
     if(ui_appname() == NULL) {
@@ -172,3 +173,47 @@
         ucx_map_cstr_put(application_properties, name, value);
     }
 }
+
+
+
+#ifndef UI_COCOA
+
+void ui_load_locale(char *locale) {
+    char *basedir = ui_get_locale_basedir();
+}
+
+#endif
+
+void uic_load_language_file(char *path) {
+    UcxMap *lang = ucx_map_new(256);
+    
+    printf("path: %s\n", path);
+    FILE *file = fopen(path, "r");
+    if(!file) {
+        printf("cannot open file: %s\n", path);
+        free(path);
+        return;
+    }
+    
+    if(ucx_properties_load(lang, file)) {
+        fprintf(stderr, "Ui Error: Cannot load locale.\n");
+    }
+    
+    fclose(file);
+    
+    ucx_map_rehash(lang);
+    
+    language = lang;
+}
+
+char* uistr(char *name) {
+    if(!language) {
+        return "missing string";
+    }
+    char *value = ucx_map_cstr_get(language, name);
+    if(!value) {
+        return "missing string";
+    } else {
+        return value;
+    }
+}

mercurial