Localization: Update POT

+ Fixed translation for the "Extruder n" category on the Printer Settings Tab
 + Fixed a crash, when scrolling inside Search imGui with some localization (e.t. Russion)
This commit is contained in:
YuSanka 2020-12-01 16:43:34 +01:00
parent 4580456bad
commit 9d34d350a5
7 changed files with 2212 additions and 2022 deletions

File diff suppressed because it is too large Load Diff

View File

@ -159,8 +159,8 @@ void PrintConfigDef::init_common_params()
def->enum_keys_map = &ConfigOptionEnum<AuthorizationType>::get_enum_values();
def->enum_values.push_back("key");
def->enum_values.push_back("user");
def->enum_labels.push_back("API key");
def->enum_labels.push_back("HTTP digest");
def->enum_labels.push_back(L("API key"));
def->enum_labels.push_back(L("HTTP digest"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<AuthorizationType>(atKeyPassword));
}
@ -534,7 +534,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("The extruder to use (unless more specific extruder settings are specified). "
"This value overrides perimeter and infill extruders, but not the support extruders.");
def->min = 0; // 0 = inherit defaults
def->enum_labels.push_back("default"); // override label for item 0
def->enum_labels.push_back(L("default")); // override label for item 0
def->enum_labels.push_back("1");
def->enum_labels.push_back("2");
def->enum_labels.push_back("3");
@ -1207,9 +1207,9 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("top");
def->enum_values.push_back("topmost");
def->enum_values.push_back("solid");
def->enum_labels.push_back("All top surfaces");
def->enum_labels.push_back("Topmost surface only");
def->enum_labels.push_back("All solid surfaces");
def->enum_labels.push_back(L("All top surfaces"));
def->enum_labels.push_back(L("Topmost surface only"));
def->enum_labels.push_back(L("All solid surfaces"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<IroningType>(IroningType::TopSurfaces));

View File

@ -1872,6 +1872,7 @@ wxString GUI_App::current_language_code_safe() const
{ "pl", "pl_PL", },
{ "uk", "uk_UA", },
{ "zh", "zh_CN", },
{ "ru", "ru_RU", },
};
wxString language_code = this->current_language_code().BeforeFirst('_');
auto it = mapping.find(language_code);

View File

@ -624,7 +624,7 @@ static bool selectable(const char* label, bool selected, ImGuiSelectableFlags fl
}
// mark a label with a ImGui::ColorMarkerHovered, if item is hovered
char* marked_label = new char[255];
char* marked_label = new char[512]; //255 symbols is not enough for translated string (e.t. to Russian)
if (hovered)
sprintf(marked_label, "%c%s", ImGui::ColorMarkerHovered, label);
else

View File

@ -83,7 +83,7 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty
options.emplace_back(Option{ boost::nowide::widen(opt_key), type,
(label + suffix).ToStdWstring(), (_(label) + suffix_local).ToStdWstring(),
gc.group.ToStdWstring(), _(gc.group).ToStdWstring(),
gc.category.ToStdWstring(), _(gc.category).ToStdWstring() });
gc.category.ToStdWstring(), GUI::Tab::translate_category(gc.category, type).ToStdWstring() });
};
for (std::string opt_key : config->keys())

View File

@ -432,6 +432,17 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
return page;
}
// Names of categories is save in English always. We translate them only for UI.
// But category "Extruder n" can't be translated regularly (using _()), so
// just for this category we should splite the title and translate "Extruder" word separately
wxString Tab::translate_category(const wxString& title, Preset::Type preset_type)
{
if (preset_type == Preset::TYPE_PRINTER && title.Contains("Extruder ")) {
return _("Extruder") + title.SubString(8, title.Last());
}
return _(title);
}
void Tab::OnActivate()
{
wxWindowUpdateLocker noUpdates(this);
@ -509,7 +520,7 @@ void Tab::update_labels_colour()
auto title = m_treectrl->GetItemText(cur_item);
for (auto page : m_pages)
{
if (_(page->title()) != title)
if (translate_category(page->title(), m_type) != title)
continue;
const wxColor *clr = !page->m_is_nonsys_values ? &m_sys_label_clr :
@ -736,7 +747,7 @@ void Tab::update_changed_tree_ui()
auto title = m_treectrl->GetItemText(cur_item);
for (auto page : m_pages)
{
if (_(page->title()) != title)
if (translate_category(page->title(), m_type) != title)
continue;
bool sys_page = true;
bool modified_page = false;
@ -1132,7 +1143,7 @@ void Tab::update_wiping_button_visibility() {
void Tab::activate_option(const std::string& opt_key, const wxString& category)
{
wxString page_title = _(category);
wxString page_title = translate_category(category, m_type);
auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item || !m_treectrl->IsVisible(cur_item))
@ -1803,7 +1814,6 @@ void TabFilament::build()
on_value_change(opt_key, value);
};
// optgroup = page->new_optgroup(_(L("Temperature")) + wxString(" °C", wxConvUTF8));
optgroup = page->new_optgroup(L("Temperature"));
Line line = { L("Nozzle"), "" };
line.append_option(optgroup->get_option("first_layer_temperature"));
@ -2515,7 +2525,7 @@ void TabPrinter::build_unregular_pages()
// Build missed extruder pages
for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) {
//# build page
const wxString& page_name = wxString::Format(L("Extruder %d"), int(extruder_idx + 1));
const wxString& page_name = wxString::Format("Extruder %d", int(extruder_idx + 1));
auto page = add_options_page(page_name, "funnel", true);
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
@ -2947,7 +2957,7 @@ void Tab::rebuild_page_tree()
{
if (!p->get_show())
continue;
auto itemId = m_treectrl->AppendItem(rootItem, _(p->title()), p->iconID());
auto itemId = m_treectrl->AppendItem(rootItem, translate_category(p->title(), m_type), p->iconID());
m_treectrl->SetItemTextColour(itemId, p->get_item_colour());
if (p->title() == selected)
item = itemId;
@ -3286,7 +3296,7 @@ bool Tab::tree_sel_change_delayed()
const auto sel_item = m_treectrl->GetSelection();
const auto selection = sel_item ? m_treectrl->GetItemText(sel_item) : "";
for (auto p : m_pages)
if (_(p->title()) == selection)
if (translate_category(p->title(), m_type) == selection)
{
page = p.get();
m_is_nonsys_values = page->m_is_nonsys_values;

View File

@ -309,6 +309,7 @@ public:
void on_roll_back_value(const bool to_sys = false);
PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false);
static wxString translate_category(const wxString& title, Preset::Type preset_type);
virtual void OnActivate();
virtual void on_preset_loaded() {}