1 /*
2 * Copyright (C) 2016-2020 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 */
19
20 #include "wui/map_tags.h"
21
22 #include <map>
23
24 #include "base/i18n.h"
25
26 namespace {
27
28 const std::map<std::string, std::string> kMapTags = {
29 /** TRANSLATORS: This is a map tag */
30 {"official", _("Official")},
31 /** TRANSLATORS: This is a map tag */
32 {"unofficial", _("Unofficial")},
33 /** TRANSLATORS: This is a map tag */
34 {"balanced", _("Balanced")},
35 /** TRANSLATORS: This is a map tag */
36 {"unbalanced", _("Unbalanced")},
37 /** TRANSLATORS: This is a map tag */
38 {"seafaring", _("Seafaring")},
39 /** TRANSLATORS: This is a map tag */
40 {"ferries", _("Ferries")},
41 /** TRANSLATORS: This is a map tag */
42 {"artifacts", _("Artifacts")},
43 /** TRANSLATORS: This is a map tag */
44 {"scenario", _("Scenario")},
45 /** TRANSLATORS: This is a map tag */
46 {"ffa", _("Free for all")},
47 /** TRANSLATORS: This is a map tag. One versus one. */
48 {"1v1", _("1v1")},
49 /** TRANSLATORS: This is a map tag */
50 {"2teams", _("Teams of 2")},
51 /** TRANSLATORS: This is a map tag */
52 {"3teams", _("Teams of 3")},
53 /** TRANSLATORS: This is a map tag */
54 {"4teams", _("Teams of 4")},
55 };
56
57 } // namespace
58
tag_exists(const std::string & tag)59 bool tag_exists(const std::string& tag) {
60 return kMapTags.count(tag) == 1;
61 }
62
localize_tag(const std::string & tag)63 const std::string localize_tag(const std::string& tag) {
64 if (tag_exists(tag)) {
65 return _((*kMapTags.find(tag)).second);
66 }
67 return tag;
68 }
69