Added timezone locale; Added new fields for timezone

pull/64/head
parent 0660ea8351
commit 43d779be92

@ -94,6 +94,13 @@ install: check
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
ldconfig -n ${DESTDIR}${PREFIX}/lib; \
fi
@for LANG in $$(find ./locale -iname "*.po" -print | sed -En "s/.+_([[:alpha:]]+)\.po/\1/p" | sort -u); do \
install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \
# PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
PKGNAME_PO="./locale/${PKGNAME}_$${LANG}.po"; [[ -f "$${PKGNAME_PO}" ]] || PKGNAME_PO= ; \
msgfmt --verbose --use-fuzzy --output-file "$${PATH_FILE_MO}" - < <(msgcat --use-first --no-wrap $${PKGNAME_PO} ./locale/*_$${LANG}.po); \
done
@echo "Install: OK"
clean:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -13,6 +13,9 @@ typedef struct {
char *comments;
char *city;
char *country;
char *zone;
double lat;
double lon;
} yon_timezone_struct;
void _yon_timezone_countries_setup(GHashTable *timezone_countries){
@ -51,18 +54,37 @@ int yon_timezone_init(){
yon_timezone_struct *timezone_info = malloc(sizeof(yon_timezone_struct));
memset(timezone_info,0,sizeof(yon_timezone_struct));
char *city = strstr(parsed[2],"/");
if (yon_char_count(parsed[2],"/")>1){
timezone_info->timezone = yon_char_new(parsed[2]);
free(yon_char_divide_search(timezone_info->timezone,"/",-1));
} else {
timezone_info->timezone = yon_char_new(parsed[2]);
}
char *city = strstr(timezone_info->timezone,"/");
if (city){
city++;
}
char *zone = yon_char_new(timezone_info->timezone);
char *temp = strstr(zone,"/");
if (temp){
temp[0]='\0';
}
timezone_info->country_code = yon_char_new(parsed[0]);
timezone_info->timezone = yon_char_new(parsed[2]);
timezone_info->city = yon_char_new(city);
timezone_info->country = yon_char_new(g_hash_table_lookup(timezone_countries,parsed[0]));
timezone_info->zone = zone;
char *coords = yon_char_new(parsed[1]);
char *pos = strstr(coords+1,"+");
char *ngt = strstr(coords+1,"-");
char *lat = coords;
char *lon = !yon_char_is_empty(pos)?yon_char_new(pos):yon_char_new(ngt);
if (parsed_size>3){
timezone_info->comments = yon_char_new(parsed[3]);
}
g_hash_table_insert(__yon_timezone,yon_char_new(parsed[2]),timezone_info);
g_hash_table_insert(__yon_timezone,yon_char_new(timezone_info->timezone),timezone_info);
yon_char_parsed_free(parsed,parsed_size);
}
@ -131,6 +153,16 @@ char *yon_timezone_get_country(const char *timezone){
return NULL;
}
char *yon_timezone_get_zone(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->zone);
}
}
return NULL;
}
#define get_utc_command(tz) yon_char_unite("TZ='",tz,"' date +%z",NULL);
char *yon_timezone_get_utc(const char *timezone){
@ -145,3 +177,20 @@ char *yon_timezone_get_utc(const char *timezone){
}
return NULL;
}
config_str yon_timezone_get_zones_from_region(char *region, size_t *size){
size_t timezones_size;
(*size) = 0;
yon_timezone_check{
config_str zones_final = NULL;
config_str timezones = (config_str)g_hash_table_get_keys_as_array(__yon_timezone,(guint*)&timezones_size);
for (size_t i=0;i<timezones_size;i++){
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezones[i]);
if (timezone_info&&!yon_char_is_empty(timezone_info->zone)&&!strcmp(timezone_info->zone,region)){
yon_char_parsed_add_or_create_if_exists(zones_final,(int*)size,timezone_info->city);
}
}
qsort(zones_final,*size,sizeof(char*),(__compar_fn_t)yon_char_parsed_compare);
return zones_final;
}
}

@ -671,6 +671,8 @@ void yon_gtk_combo_box_block_scroll(GtkComboBox *target);
//timezone section
#define timezone_locale_name "libublsettings-gtk3"
/// @brief Init timezone system
/// @return 1 if timezone system has been successfully initialised, 0 if failed
int yon_timezone_init();
@ -681,9 +683,15 @@ void yon_timezone_unref();
/// @brief Get all timezones list
/// @param size pointer for list size;
/// @return New allocated char* array with timezones
/// @return A newly allocated char* array with timezones
config_str yon_timezone_get_all(size_t *size);
/// @brief Get list of zones for specific region
/// @param region The region for which the zone search will take place;
/// @param size size pointer of zones list;
/// @return New allocated char* array with zones
config_str yon_timezone_get_zones_from_region(char *region, size_t *size);
/// @brief Get a country code for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with country code or NULL
@ -704,6 +712,11 @@ char *yon_timezone_get_city(const char *timezone);
/// @return A newly allocated char string with country or NULL
char *yon_timezone_get_country(const char *timezone);
/// @brief Get a zone for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with zone or NULL
char *yon_timezone_get_zone(const char *timezone);
/// @brief Get UTC modifier for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with UTC modifier or NULL

Loading…
Cancel
Save