Use symbols to make wml keys not translatable upon request of Ivanovic.
Also add some extra validations for the [terrain] section.
This commit is contained in:
parent
a3c9867d55
commit
57d98ce2ae
3 changed files with 43 additions and 2 deletions
|
@ -73,13 +73,19 @@ terrain_type::terrain_type(const config& cfg) :
|
|||
income_description_own_(),
|
||||
editor_group_(cfg["editor_group"])
|
||||
{
|
||||
VALIDATE(number_ != t_translation::NONE_TERRAIN,
|
||||
missing_mandatory_wml_key("terrain", "string"));
|
||||
VALIDATE(!minimap_image_.empty(),
|
||||
missing_mandatory_wml_key("terrain", "symbol_image", "string",
|
||||
t_translation::write_letter(number_)));
|
||||
VALIDATE(!name_.empty(),
|
||||
missing_mandatory_wml_key("terrain", "name", "string",
|
||||
t_translation::write_letter(number_)));
|
||||
|
||||
if(editor_image_.empty()) {
|
||||
editor_image_ = minimap_image_;
|
||||
}
|
||||
|
||||
VALIDATE(number_ != t_translation::NONE_TERRAIN, _("'string' is a mandatory key in '[terrain]'."));
|
||||
|
||||
mvt_type_.push_back(number_);
|
||||
def_type_.push_back(number_);
|
||||
const t_translation::t_list& alias = t_translation::read_list(cfg["aliasof"]);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
//! Helper function, don't call this directly.
|
||||
|
@ -63,3 +64,33 @@ void twml_exception::show(display &disp)
|
|||
|
||||
gui::show_error_message(disp, sstr.str());
|
||||
}
|
||||
|
||||
//! Returns a standard message for a missing wml key.
|
||||
//!
|
||||
//! @param section The section is which the key should appear.
|
||||
//! @param key The ommitted key.
|
||||
//! @param primary_key The primary key of the section.
|
||||
//! @param primary_value
|
||||
//! The value of the primary key (mandatory if primary key
|
||||
//! isn't empty).
|
||||
//!
|
||||
//! @return The error message.
|
||||
t_string missing_mandatory_wml_key(const std::string& section, const std::string& key,
|
||||
const std::string& primary_key, const std::string& primary_value)
|
||||
{
|
||||
utils::string_map symbols;
|
||||
symbols["section"] = section;
|
||||
symbols["key"] = key;
|
||||
if(!primary_key.empty()) {
|
||||
assert(!primary_value.empty());
|
||||
|
||||
symbols["primary_key"] = primary_key;
|
||||
symbols["primary_value"] = primary_value;
|
||||
|
||||
return t_string(vgettext("In section '[$section|]' where '$primary_key| = "
|
||||
"$primary_value' the mandatory key '$key|' isn't set.", symbols));
|
||||
} else {
|
||||
return t_string(vgettext("In section '[$section|]' the "
|
||||
"mandatory key '$key|' isn't set.", symbols));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,5 +58,9 @@ struct twml_exception
|
|||
void show(display &disp);
|
||||
};
|
||||
|
||||
//! Returns a standard message for a missing wml key.
|
||||
t_string missing_mandatory_wml_key(const std::string& section, const std::string& key,
|
||||
const std::string& primary_key = "", const std::string& primary_value = "");
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue