mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Make templates localizable (Closes #100)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/locale.hpp>
|
||||
#include <data/localized_string.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/symbol_font.hpp>
|
||||
@@ -118,3 +119,23 @@ String tr(const Package& pkg, const String& subcat, const String& key, DefaultLo
|
||||
}
|
||||
return loc->tr(subcat, key, def);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : LocalizedString
|
||||
|
||||
String const& LocalizedString::get(String const& locale) const {
|
||||
auto it = translations.find(locale);
|
||||
if (it != translations.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
return default_;
|
||||
}
|
||||
}
|
||||
|
||||
String const& LocalizedString::get(Locale const& locale) const {
|
||||
return get(locale.name());
|
||||
}
|
||||
|
||||
String const& LocalizedString::get() const {
|
||||
if (translations.empty()) return default_;
|
||||
return get(the_locale->name());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user