mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Make templates localizable (Closes #100)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#pragma once
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
|
||||
class Locale;
|
||||
|
||||
// ----------------------------------------------------------------------------- : LocalizedString
|
||||
|
||||
/// Translations of a text in a template
|
||||
class LocalizedString {
|
||||
public:
|
||||
String default_; //< Value in all other locales
|
||||
unordered_map<String, String> translations;
|
||||
|
||||
/// Translate
|
||||
String const& get(Locale const& locale) const;
|
||||
String const& get(String const& locale) const;
|
||||
String const& get() const;
|
||||
|
||||
bool empty() const { return default_.empty(); }
|
||||
};
|
||||
|
||||
#define REFLECT_LOCALIZED_N(name, var) \
|
||||
do { \
|
||||
handler.handle(name, var.default_); \
|
||||
handler.handle(_("localized_") name, var.translations); \
|
||||
} while (0)
|
||||
|
||||
#define REFLECT_LOCALIZED(var) REFLECT_LOCALIZED_N(_(#var), var)
|
||||
Reference in New Issue
Block a user