Array* Time::calculate_decompose(STATE) { if(!decomposed_->nil_p()) return decomposed_; struct tm64 tm = get_tm(); /* update Time::TM_FIELDS when changing order of fields */ Array* ary = Array::create(state, 11); ary->set(state, 0, Integer::from(state, tm.tm_sec)); ary->set(state, 1, Integer::from(state, tm.tm_min)); ary->set(state, 2, Integer::from(state, tm.tm_hour)); ary->set(state, 3, Integer::from(state, tm.tm_mday)); ary->set(state, 4, Integer::from(state, tm.tm_mon + 1)); ary->set(state, 5, Integer::from(state, tm.tm_year)); ary->set(state, 6, Integer::from(state, tm.tm_wday)); ary->set(state, 7, Integer::from(state, tm.tm_yday + 1)); ary->set(state, 8, RBOOL(tm.tm_isdst)); if (zone_->nil_p()) { if(offset_->nil_p() && tm.tm_zone) { zone(state, locale_string(state, tm.tm_zone)); } else { zone(state, nil<String>()); } } ary->set(state, 9, zone()); // Cache it. decomposed(state, ary); return ary; }
static void test_strings(CuTest * tc) { const char * data = "{\"strings\": { \"de\" : { \"move\" : \"NACH\", \"study\" : \"LERNEN\" }}}"; const struct locale * lang; cJSON *json = cJSON_Parse(data); CuAssertPtrNotNull(tc, json); test_cleanup(); lang = get_or_create_locale("de"); CuAssertPtrNotNull(tc, lang); CuAssertPtrEquals(tc, NULL, (void *)locale_string(lang, "move")); json_config(json); CuAssertStrEquals(tc, "NACH", locale_string(lang, "move")); CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "study")); }
// Returns the environment time zone. String* Time::env_zone(STATE) { struct tm64 tm; tzset(); localtime64_r(&seconds_, &tm); if(tm.tm_zone) { return locale_string(state, tm.tm_zone); } else { return nil<String>(); } }
static void test_skills(CuTest * tc) { const char * data = "{\"skills\": { \"de\" : { \"alchemy\" : \"ALCHEMIE\", \"crossbow\" : [ \"ARMBRUST\", \"KREUZBOGEN\" ] }}}"; const struct locale * lang; cJSON *json = cJSON_Parse(data); test_cleanup(); lang = get_or_create_locale("de"); CuAssertPtrNotNull(tc, json); CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang)); json_config(json); CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang)); CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("armbrust", lang)); CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("kreuz", lang)); CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang)); CuAssertStrEquals(tc, "ALCHEMIE", locale_string(lang, "skill::alchemy")); CuAssertStrEquals(tc, "ARMBRUST", locale_string(lang, "skill::crossbow")); test_cleanup(); }
////////// TranslateString OP_STATUS QuickUICreator::TranslateString(const OpStringC8 & string_id, OpString & translated_string) { Str::LocaleString locale_string(string_id.CStr()); RETURN_IF_ERROR(g_languageManager->GetString(locale_string, translated_string)); if (translated_string.IsEmpty()) { OP_ASSERT(!"untranslated string"); m_log.OutputEntry("WARNING: untranslated string %s", string_id); RETURN_IF_ERROR(translated_string.Set(string_id)); } return OpStatus::OK; }
static void test_keywords(CuTest * tc) { const char * data = "{\"keywords\": { \"de\" : { \"move\" : \"NACH\", \"study\" : [ \"LERNEN\", \"STUDIEREN\" ] }}}"; const struct locale * lang; cJSON *json = cJSON_Parse(data); test_cleanup(); lang = get_or_create_locale("de"); CuAssertPtrNotNull(tc, json); CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang)); json_config(json); CuAssertIntEquals(tc, K_STUDY, get_keyword("studiere", lang)); CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang)); CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang)); CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "keyword::study")); test_cleanup(); }
void register_special_direction(struct locale *lang, const char *name) { const char *token = locale_string(lang, name, false); if (token) { void **tokens = get_translations(lang, UT_SPECDIR); variant var; char *str = strdup(name); var.v = str; addtoken((struct tnode **)tokens, token, var); if (lang == locales) { dir_lookup *dl = malloc(sizeof(dir_lookup)); dl->name = str; dl->oldname = token; dl->next = dir_name_lookup; dir_name_lookup = dl; } } else { log_debug("no translation for spec_direction '%s' in locale '%s'\n", name, locale_name(lang)); } }