25 #include <boost/algorithm/string.hpp>
28 #define LOG_CS LOG_STREAM_NAMELESS(err, log_network)
32 typedef std::map<std::string, std::string> plain_string_map;
43 std::string fast_interpolate_variables_into_string(
const std::string &str,
const plain_string_map *
const symbols)
45 std::string res = str;
48 for(
const plain_string_map::value_type& sym : *symbols) {
49 boost::replace_all(res,
"$" + sym.first, sym.second);
67 plain_string_map escaped;
79 const std::string& res =
80 fast_interpolate_variables_into_string(
format, &escaped);
96 config* locale = addon.
find_child(
"translation",
"language", locale_id).ptr();
99 (*locale)[
"language"] = locale_id;
101 (*locale)[
"supported"] =
true;
107 const std::string& fn = file[
"name"].str();
108 if(boost::algorithm::ends_with(fn,
".po")) {
115 if(dir[
"name"] ==
"LC_MESSAGES") {
129 LOG_CS <<
"Could not find toplevel [dir] tag";
134 if(dir->find_child(
"file",
"name",
"COPYING.txt")
135 || dir->find_child(
"file",
"name",
"COPYING")
136 || dir->find_child(
"file",
"name",
"copying.txt")
137 || dir->find_child(
"file",
"name",
"Copying.txt")
138 || dir->find_child(
"file",
"name",
"COPYING.TXT"))
145 if (contents.empty()) {
151 copying[
"name"] =
"COPYING.txt";
152 copying[
"contents"] = contents;
157 std::map<version_info, config> version_map;
160 version_map.emplace(
version_info(version[
"version"]), version);
169 data.remove_children(
"file", [&
f](
const config&
d) {
return f[
"name"] ==
d[
"name"]; });
173 auto data_dir =
data.find_child(
"dir",
"name", dir[
"name"]);
176 data.remove_children(
"dir", [&dir](
const config&
d) {
return dir[
"name"] ==
d[
"name"]; });
180 return data.has_child(
"file") ||
data.has_child(
"dir");
187 data.add_child(
"file",
f);
191 config* data_dir =
data.find_child(
"dir",
"name", dir[
"name"]).ptr();
193 data_dir = &
data.add_child(
"dir");
194 (*data_dir)[
"name"] = dir[
"name"];
static lg::log_domain log_network("network")
A config object defines a single node in a WML file, with access to child nodes.
const_attr_itors attribute_range() const
optional_config_impl< config > find_child(config_key_type key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
config & add_child(config_key_type key)
Represents version numbers.
Definitions for the interface to Wesnoth Markup Language (WML).
Declarations for File-IO.
Standard logging facilities (interface).
std::string format_addon_feedback_url(const std::string &format, const config ¶ms)
Format a feedback URL for an add-on.
void data_apply_addlist(config &data, const config &addlist)
const std::string illegal_markup_chars
Markup characters recognized by GUI1 code.
void find_translations(const config &base_dir, config &addon)
Scans an add-on archive directory for translations.
bool data_apply_removelist(config &data, const config &removelist)
void support_translation(config &addon, const std::string &locale_id)
std::map< version_info, config > get_version_map(config &addon)
void add_license(config &cfg)
Adds a COPYING.txt file with the full text of the GNU GPL to an add-on.
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
std::string urlencode(std::string_view str)
Percent-escape characters in a UTF-8 string intended to be part of a URL.