Make localization parameters better, and add a single frame animation helper
This commit is contained in:
@@ -71,7 +71,7 @@ inline void set(LanguageCode lang_code, Key key, const std::string &text) {
|
||||
localized_strings[join_keys(lang_code, key)] = parse_localized(text);
|
||||
}
|
||||
|
||||
inline std::string get(mrb_state *mrb, Key key, mrb_value hash) {
|
||||
inline std::string get(mrb_state *mrb, Key key, const std::unordered_map<std::string, std::string> ¶ms) {
|
||||
auto it = localized_strings.find(join_keys(current_language, key));
|
||||
if (it == localized_strings.end())
|
||||
return "Localization not set!";
|
||||
@@ -85,15 +85,12 @@ inline std::string get(mrb_state *mrb, Key key, mrb_value hash) {
|
||||
if (!seg.is_var) {
|
||||
result += seg.text;
|
||||
} else {
|
||||
mrb_sym sym = get_var_sym(mrb, seg.text);
|
||||
if (mrb_nil_p(hash) || mrb_nil_p(mrb_hash_get(mrb, hash, mrb_symbol_value(sym)))) {
|
||||
auto param_it = params.find(seg.text);
|
||||
if (param_it == params.end()) {
|
||||
result += "%{" + seg.text + "}";
|
||||
continue;
|
||||
}
|
||||
mrb_value val = mrb_hash_get(mrb, hash, mrb_symbol_value(sym));
|
||||
if (mrb_nil_p(val))
|
||||
continue;
|
||||
result += mrb_str_to_cstr(mrb, val);
|
||||
result += param_it->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user