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:
@@ -4,6 +4,9 @@ Magic Set Editor changelog, for the details see `git log`
|
||||
HEAD: new items added as changes are made
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Template features:
|
||||
* Localization of game/stylesheet/symbol_font names is now done in those templates, instead of via the program-wide locale file. (#100)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
version 2.1.2, 2020-09-28
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ Fields are part of the [[file:style triangle]]:
|
||||
* @color@
|
||||
* @info@
|
||||
| @name@ [[type:string]] ''required'' Name of the field.
|
||||
| @description@ [[type:string]] @""@ Description of the field, shown in the status bar when the mouse is over the field.
|
||||
| @description@ [[type:localized string]] @""@ Description of the field, shown in the status bar when the mouse is over the field.
|
||||
| @icon@ [[type:filename]] Filename of an icon for this field, used for automatically generated [[type:statistics category]]s.
|
||||
| @editable@ [[type:boolean]] @true@ Can values of this field be edited?
|
||||
| @save value@ [[type:boolean]] @true@ Should values of this field be saved to files? Should be disabled for values that are generated by scripts.
|
||||
@@ -38,7 +38,7 @@ Fields are part of the [[file:style triangle]]:
|
||||
| @card list width@ [[type:int]] @100@ Width of the card list column in pixels.
|
||||
| @card list visible@ [[type:boolean]] @false@ Should this field be shown in the card list by default?
|
||||
| @card list allow@ [[type:boolean]] @true@ Should this field be allowed in the card list at all?
|
||||
| @card list name@ [[type:string]] field name Alternate name to use for the card list, for example an abbreviation.
|
||||
| @card list name@ [[type:localized string]] field name Alternate name to use for the card list, for example an abbreviation.
|
||||
| @card list alignment@ [[type:alignment]] @left@ Alignment of the card list column.
|
||||
| @sort script@ [[type:script]] Alternate way to sort the card list when using this column to sort the list.
|
||||
|
||||
|
||||
@@ -14,18 +14,19 @@ The menu consists of a number of entries, either items, separators or submenus.
|
||||
* @line@, a separating line.
|
||||
* @submenu@, a submenu.
|
||||
| @name@ [[type:string]] ''required'' Name of this menu item, corresponding to the code to insert.
|
||||
| @label@ [[type:localized string]] name Label to show in the menu.
|
||||
| @prompt@ [[type:localized string]] Prompt to use for the pop up box with @custom@ type
|
||||
| @items@ [[type:list]] of [[type:insert symbol menu|submenu items]] Items in the submenu, when items are present the @type@ is set to @"submenu"@.
|
||||
|
||||
In the user interface the items are shown as @"menu item {name}"@, the [[type:locale]] should be used to give a beter label.
|
||||
|
||||
For custom items the dialog will be titled @"title {name}"@ and have message text @"message {name}"@, again this should be changed in the locale.
|
||||
For custom items the dialog will be titled with the @label@ and have message text @prompt@.
|
||||
|
||||
--Examples--
|
||||
A menu for magic mana symbols (simplified). Containing all types of items.
|
||||
>insert symbol menu:
|
||||
> item:
|
||||
> type: custom
|
||||
> name: colorless
|
||||
> name: Generic
|
||||
> prompt: How much generic mana?
|
||||
> item:
|
||||
> type: line
|
||||
> item: W
|
||||
@@ -34,6 +35,9 @@ A menu for magic mana symbols (simplified). Containing all types of items.
|
||||
> item: R
|
||||
> item: G
|
||||
> item:
|
||||
> label: Complex
|
||||
> name: cplx
|
||||
> item:
|
||||
> type: line
|
||||
> item:
|
||||
> name: hybrid
|
||||
|
||||
@@ -35,12 +35,15 @@ There are usually no other files in the package.
|
||||
| @error@ [[type:map]] of [[type:string]]s Error messages.
|
||||
| @type@ [[type:map]] of [[type:string]]s Types of objects for error messages.
|
||||
| @game@ [[type:map]] of [[type:map]] of [[type:string]]s
|
||||
Deprecated since MSE 2.1.3, use @localized_...@ instead.<br/>
|
||||
Translations for specific [[type:game]]s.<br/>
|
||||
Field names and field descriptions are looked up in the locale, if they are found the translation is used, otherwise the value from the game file.<br/>
|
||||
Extra keys not present in the English locale can be added here.
|
||||
| @stylesheet@ [[type:map]] of [[type:map]] of [[type:string]]s
|
||||
Deprecated since MSE 2.1.3, use @localized_...@ instead.<br/>
|
||||
Translations for specific [[type:stylesheet]]s.
|
||||
| @symbol font@ [[type:map]] of [[type:map]] of [[type:string]]s
|
||||
Deprecated since MSE 2.1.3, use @localized_...@ instead.<br/>
|
||||
Translations for specific [[type:symbol font]]s, in particular the "insert symbol" menu.
|
||||
|
||||
Some of the items can contain placeholders for other values, for example:
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
Localized strings
|
||||
|
||||
A 'localized string' is a [[type:map]] of [[type::string]]s, indexed by locale name.
|
||||
It is used to translate games and stylesheets to other user interface languages.
|
||||
|
||||
Localized strings can be given with a @localized@ prefix on the property name.
|
||||
For example, a field has a @description@ which is a [[type::string]], and a @localized_description@ for localized variants. So
|
||||
|
||||
>field:
|
||||
> name: cost
|
||||
> description: How much this card costs
|
||||
> localized description:
|
||||
> en_US: How much this card costs
|
||||
> nl_NL: Hoeveel deze kaart kost
|
||||
@@ -12,7 +12,7 @@ Statistics dimensions are automatically generated for all [[type:statistics dime
|
||||
--Properties--
|
||||
! Property Type Default Description
|
||||
| @name@ [[type:string]] ''required'' Name of this category.
|
||||
| @description@ [[type:string]] @""@ A description of the category, currently not used.
|
||||
| @description@ [[type:localized string]] @""@ A description of the category, currently not used.
|
||||
| @position hint@ [[type:string]] @0@ Hint for ordering category, lower numbers are at the top of the list.
|
||||
| @icon@ [[type:filename]] Filename of an icon for this category, the image should be 21x21 pixels.
|
||||
| @type@ [[type:graph type]] @"bar"@ Type of graph to use.
|
||||
|
||||
@@ -13,7 +13,7 @@ Categories are also automatically generated from dimensions.
|
||||
--Properties--
|
||||
! Property Type Default Description
|
||||
| @name@ [[type:string]] ''required'' Name of this dimension, used as an axis label and a label for automatically generated categories.
|
||||
| @description@ [[type:string]] @""@ A description of the dimension, currently not used.
|
||||
| @description@ [[type:localized string]] @""@ A description of the dimension, currently not used.
|
||||
| @position hint@ [[type:string]] @0@ Hint for ordering dimensions.
|
||||
| @icon@ [[type:filename]] Filename of an icon for this dimension.
|
||||
| @script@ [[type:script]] ''required'' Script that generates a value for each card in the set.
|
||||
|
||||
+5
-5
@@ -47,8 +47,8 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(type);
|
||||
}
|
||||
REFLECT(name);
|
||||
REFLECT(caption);
|
||||
REFLECT(description);
|
||||
REFLECT_LOCALIZED(caption);
|
||||
REFLECT_LOCALIZED(description);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(editable);
|
||||
REFLECT(save_value);
|
||||
@@ -59,15 +59,15 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(card_list_width);
|
||||
REFLECT(card_list_visible);
|
||||
REFLECT(card_list_allow);
|
||||
REFLECT(card_list_name);
|
||||
REFLECT_LOCALIZED(card_list_name);
|
||||
REFLECT(sort_script);
|
||||
REFLECT_N("card_list_alignment", card_list_align);
|
||||
}
|
||||
|
||||
void Field::after_reading(Version ver) {
|
||||
name = canonical_name_form(name);
|
||||
if(caption.empty()) caption = name_to_caption(name);
|
||||
if(card_list_name.empty()) card_list_name = capitalize(caption);
|
||||
if(caption.default_.empty()) caption.default_ = name_to_caption(name);
|
||||
if(card_list_name.default_.empty()) card_list_name.default_ = capitalize(caption.default_);
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
+4
-3
@@ -13,6 +13,7 @@
|
||||
#include <util/alignment.hpp>
|
||||
#include <util/age.hpp>
|
||||
#include <util/rotation.hpp>
|
||||
#include <data/localized_string.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <script/dependency.hpp>
|
||||
#include <script/image.hpp>
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
|
||||
size_t index; ///< Used by IndexMap
|
||||
String name; ///< Name of the field, for refering to it from scripts and files
|
||||
String caption; ///< Caption for NativeLookEditor
|
||||
String description; ///< Description, used in status bar
|
||||
LocalizedString caption; ///< Caption for NativeLookEditor
|
||||
LocalizedString description;///< Description, used in status bar
|
||||
String icon_filename; ///< Filename for an icon (for list of fields)
|
||||
bool editable; ///< Can values of this field be edited?
|
||||
bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields.
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
UInt card_list_width; ///< Width of the card list column (pixels).
|
||||
bool card_list_visible;///< Is this field shown in the card list?
|
||||
bool card_list_allow; ///< Is this field allowed to appear in the card list?
|
||||
String card_list_name; ///< Alternate name to use in card list.
|
||||
LocalizedString card_list_name; ///< Name to use in card list.
|
||||
Alignment card_list_align; ///< Alignment of the card list colummn.
|
||||
OptionalScript sort_script; ///< The script to use when sorting this, if not the value.
|
||||
Dependencies dependent_scripts; ///< Scripts that depend on values of this field
|
||||
|
||||
@@ -64,7 +64,7 @@ String InfoValue::toString() const {
|
||||
return value;
|
||||
}
|
||||
bool InfoValue::update(Context& ctx) {
|
||||
if (value.empty()) value = field().caption;
|
||||
if (value.empty()) value = field().caption.get();
|
||||
bool change = field().script.invokeOn(ctx, value);
|
||||
Value::update(ctx);
|
||||
return change;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -64,7 +64,7 @@ StatsDimension::StatsDimension(const Field& field)
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) {
|
||||
if (!automatic) {
|
||||
REFLECT(name);
|
||||
REFLECT(description);
|
||||
REFLECT_LOCALIZED(description);
|
||||
REFLECT(position_hint);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(script);
|
||||
@@ -98,7 +98,7 @@ StatsCategory::StatsCategory(const StatsDimensionP& dim)
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsCategory) {
|
||||
if (!automatic) {
|
||||
REFLECT(name);
|
||||
REFLECT(description);
|
||||
REFLECT_LOCALIZED(description);
|
||||
REFLECT(position_hint);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(type);
|
||||
|
||||
+11
-10
@@ -11,6 +11,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <data/graph_type.hpp>
|
||||
#include <data/localized_string.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
|
||||
class Field;
|
||||
@@ -28,7 +29,7 @@ public:
|
||||
|
||||
const bool automatic; ///< Based on a card field?
|
||||
String name; ///< Name of this dimension
|
||||
String description; ///< Description, used in status bar
|
||||
LocalizedString description; ///< Description, used in status bar
|
||||
int position_hint; ///< Hint for the ordering
|
||||
String icon_filename; ///< Icon for lists
|
||||
Bitmap icon; ///< The loaded icon (optional of course)
|
||||
@@ -52,15 +53,15 @@ public:
|
||||
StatsCategory();
|
||||
StatsCategory(const StatsDimensionP&);
|
||||
|
||||
const bool automatic; ///< Automatically generated?
|
||||
String name; ///< Name/label
|
||||
String description; ///< Description, used in status bar
|
||||
int position_hint; ///< Hint for the ordering
|
||||
String icon_filename; ///< Icon for lists
|
||||
Bitmap icon; ///< The loaded icon (optional of course)
|
||||
vector<String> dimension_names;///< Names of the dimensions to use
|
||||
vector<StatsDimensionP> dimensions; ///< Actual dimensions
|
||||
GraphType type; ///< Type of graph to use
|
||||
const bool automatic; ///< Automatically generated?
|
||||
String name; ///< Name/label
|
||||
LocalizedString description; ///< Description, used in status bar
|
||||
int position_hint; ///< Hint for the ordering
|
||||
String icon_filename; ///< Icon for lists
|
||||
Bitmap icon; ///< The loaded icon (optional of course)
|
||||
vector<String> dimension_names; ///< Names of the dimensions to use
|
||||
vector<StatsDimensionP> dimensions; ///< Actual dimensions
|
||||
GraphType type; ///< Type of graph to use
|
||||
|
||||
/// Initialize dimensions from dimension_names
|
||||
void find_dimensions(const vector<StatsDimensionP>& available);
|
||||
|
||||
+21
-20
@@ -52,8 +52,8 @@ IMPLEMENT_REFLECTION(SymbolFont) {
|
||||
REFLECT_N("vertical_space", spacing.height);
|
||||
WITH_DYNAMIC_ARG(symbol_font_for_reading, this);
|
||||
REFLECT(symbols);
|
||||
REFLECT(scale_text);
|
||||
REFLECT(insert_symbol_menu);
|
||||
REFLECT(scale_text);
|
||||
REFLECT(insert_symbol_menu);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolInFont
|
||||
@@ -460,11 +460,11 @@ String InsertSymbolMenu::getCode(int id, const SymbolFont& font) const {
|
||||
} else if (id == 0 && type == Type::CODE) {
|
||||
return name;
|
||||
} else if (id == 0 && type == Type::CUSTOM) {
|
||||
String caption = tr(font, _("title"), name, capitalize_sentence);
|
||||
String message = tr(font, _("message"), name, capitalize_sentence);
|
||||
return wxGetTextFromUser(message, caption);
|
||||
String title = this->label.get();
|
||||
title.Replace(_("&"), _("")); // remove underlines
|
||||
return wxGetTextFromUser(prompt.get(), title);
|
||||
}
|
||||
return wxEmptyString;
|
||||
return String();
|
||||
}
|
||||
|
||||
wxMenu* InsertSymbolMenu::makeMenu(int id, SymbolFont& font) const {
|
||||
@@ -478,17 +478,18 @@ wxMenu* InsertSymbolMenu::makeMenu(int id, SymbolFont& font) const {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wxMenuItem* InsertSymbolMenu::makeMenuItem(wxMenu* parent, int first_id, SymbolFont& font) const {
|
||||
wxString menu_name = tr(font, _("menu_item"), name, capitalize);
|
||||
String label = this->label.get();
|
||||
// ensure that there is not actually an accelerator string,
|
||||
menu_name.Replace(_("\t "),_("\t"));
|
||||
label.Replace(_("\t "), _("\t"));
|
||||
#ifdef __WXMSW__
|
||||
menu_name.Replace(_("\t"),_("\t ")); // by prepending " "
|
||||
label.Replace(_("\t"), _("\t ")); // by prepending " "
|
||||
#else
|
||||
menu_name.Replace(_("\t"),_(" ")); // by simply dropping the \t
|
||||
label.Replace(_("\t"), _(" ")); // by simply dropping the \t
|
||||
#endif
|
||||
if (type == Type::SUBMENU) {
|
||||
wxMenuItem* item = new wxMenuItem(parent, wxID_ANY, menu_name,
|
||||
wxMenuItem* item = new wxMenuItem(parent, wxID_ANY, label,
|
||||
wxEmptyString, wxITEM_NORMAL,
|
||||
makeMenu(first_id, font));
|
||||
item->SetBitmap(wxNullBitmap);
|
||||
@@ -497,7 +498,7 @@ wxMenuItem* InsertSymbolMenu::makeMenuItem(wxMenu* parent, int first_id, SymbolF
|
||||
wxMenuItem* item = new wxMenuItem(parent, wxID_SEPARATOR);
|
||||
return item;
|
||||
} else {
|
||||
wxMenuItem* item = new wxMenuItem(parent, first_id, menu_name);
|
||||
wxMenuItem* item = new wxMenuItem(parent, first_id, label);
|
||||
// Generate bitmap for use on this item
|
||||
SymbolInFont* symbol = nullptr;
|
||||
if (type == Type::CUSTOM) {
|
||||
@@ -527,24 +528,24 @@ IMPLEMENT_REFLECTION_ENUM(InsertSymbolMenu::Type) {
|
||||
VALUE_N("submenu", InsertSymbolMenu::Type::SUBMENU);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(InsertSymbolMenu) {
|
||||
IMPLEMENT_REFLECTION(InsertSymbolMenu) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE_AND(items.empty()) {
|
||||
REFLECT_NAMELESS(name);
|
||||
} else {
|
||||
// complex values are groups
|
||||
REFLECT(type);
|
||||
REFLECT(name);
|
||||
REFLECT_LOCALIZED(label);
|
||||
REFLECT_LOCALIZED(prompt);
|
||||
REFLECT(items);
|
||||
if (Handler::isReading && !items.empty()) type = Type::SUBMENU;
|
||||
}
|
||||
}
|
||||
template <> void GetDefaultMember::handle(const InsertSymbolMenu& m) {
|
||||
handle(m.name);
|
||||
}
|
||||
template <> void GetMember::handle(const InsertSymbolMenu& m) {
|
||||
handle(_("type"), m.type);
|
||||
handle(_("name"), m.name);
|
||||
handle(_("items"), m.items);
|
||||
|
||||
void after_reading(InsertSymbolMenu& m, Version ver) {
|
||||
assert(symbol_font_for_reading());
|
||||
if (m.label.empty()) m.label.default_ = tr(*symbol_font_for_reading(), _("menu_item"), m.name, capitalize);
|
||||
if (m.prompt.empty()) m.prompt.default_ = tr(*symbol_font_for_reading(), _("message"), m.name, capitalize_sentence);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFontRef
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/alignment.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <data/localized_string.hpp>
|
||||
#include <data/font.hpp>
|
||||
#include <wx/regex.h>
|
||||
|
||||
@@ -124,6 +125,8 @@ public:
|
||||
};
|
||||
Type type;
|
||||
String name;
|
||||
LocalizedString label; // text of menu item
|
||||
LocalizedString prompt; // prompt for dialog box if type == CUSTOM
|
||||
vector<InsertSymbolMenuP> items;
|
||||
|
||||
/// Number of ids used (recursive)
|
||||
@@ -139,6 +142,8 @@ private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
void after_reading(InsertSymbolMenu&, Version ver);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFontRef
|
||||
|
||||
/// A reference to an actual symbol font
|
||||
|
||||
@@ -355,7 +355,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) {
|
||||
// set status text
|
||||
wxFrame* frame = dynamic_cast<wxFrame*>( wxGetTopLevelParent(this) );
|
||||
if (frame) {
|
||||
frame->SetStatusText(hovered_viewer ? hovered_viewer->getField()->description : String());
|
||||
frame->SetStatusText(hovered_viewer ? hovered_viewer->getField()->description.get() : String());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +225,7 @@ void CardListBase::rebuild() {
|
||||
if (f.second->card_list_align & ALIGN_RIGHT) align = wxLIST_FORMAT_RIGHT;
|
||||
else if (f.second->card_list_align & ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE;
|
||||
else align = wxLIST_FORMAT_LEFT;
|
||||
InsertColumn((long)column_fields.size(),
|
||||
tr(*set->game, f.second->card_list_name, identity),
|
||||
align, cs.width);
|
||||
InsertColumn((long)column_fields.size(), f.second->card_list_name.get(), align, cs.width);
|
||||
column_fields.push_back(f.second);
|
||||
}
|
||||
// determine sort settings
|
||||
|
||||
@@ -67,7 +67,7 @@ void CardListColumnSelectDialog::initList() {
|
||||
// Init items
|
||||
Color window_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
FOR_EACH(c, columns) {
|
||||
list->Append(tr(*game, c.field->card_list_name, identity));
|
||||
list->Append(c.field->card_list_name.get());
|
||||
// check
|
||||
int i = list->GetCount() - 1;
|
||||
list->Check(i, c.settings.visible);
|
||||
@@ -80,7 +80,7 @@ void CardListColumnSelectDialog::initList() {
|
||||
|
||||
void CardListColumnSelectDialog::refreshItem(int i) {
|
||||
list->Check (i, columns[i].settings.visible);
|
||||
list->SetString(i, tr(*game, columns[i].field->card_list_name, identity) );
|
||||
list->SetString(i, columns[i].field->card_list_name.get());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
@@ -39,9 +39,7 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
// draw label
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
// TODO : tr using stylesheet or using game?
|
||||
dc.DrawText(tr(getStylePackage(), v.getField()->caption, identity),
|
||||
RealPoint(margin_left - v.bounding_box.x, 1));
|
||||
dc.DrawText(v.getField()->caption.get(), RealPoint(margin_left - v.bounding_box.x, 1));
|
||||
}
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
@@ -64,8 +62,7 @@ void NativeLookEditor::resizeViewers() {
|
||||
// width of the label string
|
||||
int w;
|
||||
Style& s = *v->getStyle();
|
||||
String text = tr(getStylePackage(), s.fieldP->caption, identity);
|
||||
dc.GetTextExtent(text,&w,nullptr);
|
||||
dc.GetTextExtent(s.fieldP->caption.get(), &w, nullptr);
|
||||
label_width = max(label_width, w + label_margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,9 @@ private:
|
||||
|
||||
// ----------------------------------------------------------------------------- : Collections : maps
|
||||
|
||||
template <typename V>
|
||||
ScriptValueP get_member(const map<String,V>& m, const String& name) {
|
||||
typename map<String,V>::const_iterator it = m.find(name);
|
||||
template <typename Container>
|
||||
ScriptValueP get_member(const Container& m, const String& name) {
|
||||
auto it = m.find(name);
|
||||
if (it != m.end()) {
|
||||
return to_script(it->second);
|
||||
} else {
|
||||
@@ -403,6 +403,10 @@ inline ScriptValueP to_script(const map<K,V>* v) {
|
||||
return make_intrusive<ScriptMap<map<K,V>>>(v);
|
||||
}
|
||||
template <typename K, typename V>
|
||||
inline ScriptValueP to_script(const unordered_map<K,V>* v) {
|
||||
return make_intrusive<ScriptMap<unordered_map<K,V>>>(v);
|
||||
}
|
||||
template <typename K, typename V>
|
||||
inline ScriptValueP to_script(const IndexMap<K,V>* v) {
|
||||
return make_intrusive<ScriptMap<IndexMap<K,V>>>(v);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
template <typename T> void handle(const Scriptable<T>& );
|
||||
template <typename T> void handle(const vector<T>& c) { value = to_script(&c); }
|
||||
template <typename K, typename V> void handle(const map<K,V>& c) { value = to_script(&c); }
|
||||
template <typename K, typename V> void handle(const unordered_map<K,V>& c) { value = to_script(&c); }
|
||||
template <typename K, typename V> void handle(const IndexMap<K,V>& c) { value = to_script(&c); }
|
||||
template <typename K, typename V> void handle(const DelayedIndexMaps<K,V>&) {}
|
||||
template <typename K, typename V> void handle(const DelayedIndexMapsData<K,V>& c);
|
||||
|
||||
@@ -49,9 +49,11 @@ String identity(const String&);
|
||||
String tr(LocaleCategory cat, const String& key, DefaultLocaleFun def = warn_and_identity);
|
||||
|
||||
/// Translate 'key' in the for a Package using the current locale
|
||||
[[deprecated]]
|
||||
String tr(const Package&, const String& key, DefaultLocaleFun def);
|
||||
|
||||
/// Translate 'key' in the for a Package using the current locale
|
||||
[[deprecated]]
|
||||
String tr(const Package&, const String& subcat, const String& key, DefaultLocaleFun def);
|
||||
|
||||
/// A localized string for menus
|
||||
|
||||
Reference in New Issue
Block a user