You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.5 KiB
42 lines
1.5 KiB
#include "libublsettings.h"
|
|
|
|
#define locales_path "/usr/share/i18n/locales/"
|
|
|
|
struct yon_locale {
|
|
char *code;
|
|
char *lang_ab;
|
|
char *territory;
|
|
char *language;
|
|
char *lang_name;
|
|
char *title;
|
|
};
|
|
|
|
struct yon_locale *yon_lang_new(){
|
|
struct yon_locale *cur_locale = malloc(sizeof(struct yon_locale));
|
|
memset(cur_locale,0,sizeof(struct yon_locale));
|
|
return cur_locale;
|
|
}
|
|
|
|
void yon_locale_set(struct yon_locale *target,char *locale_name){
|
|
int size;
|
|
char *path = yon_char_unite(locales_path,locale_name,NULL);
|
|
config_str *locale_string = yon_file_open(path,&size);
|
|
target->code = yon_char_new(locale_name);
|
|
target->lang_ab = yon_char_parsed_check_exist_begins_with(locale_string,size,"lang_ab");
|
|
target->territory = yon_char_parsed_check_exist_begins_with(locale_string,size,"territory");
|
|
target->language = yon_char_parsed_check_exist_begins_with(locale_string,size,"language");
|
|
target->lang_name = yon_char_parsed_check_exist_begins_with(locale_string,size,"lang_name");
|
|
target->title = yon_char_parsed_check_exist_begins_with(locale_string,size,"title");
|
|
yon_char_parsed_free(locale_string,size);
|
|
free(path);
|
|
}
|
|
|
|
void yon_locale_init(){
|
|
int size;
|
|
config_str *locales_list = yon_dir_get_contents(locales_path,&size);
|
|
for (int i=0;i<size;i++){
|
|
if (!stcmp(locales_list,".")||!strcmp(locales_list,"..")) continue;
|
|
struct yon_locale *cur_locale = yon_lang_new();
|
|
yon_locale_set(cur_locale,locales_list[i]);
|
|
}
|
|
} |