Update localization:

* 2D.pm, 3DPreview.pm, PreviewData.cpp are marked by L()
* use translating function in 3DScene.cpp
This commit is contained in:
YuSanka 2018-02-26 16:23:44 +01:00
parent e05493bd90
commit 7047f4365a
5 changed files with 60 additions and 41 deletions

View File

@ -13,6 +13,8 @@ use Wx qw(wxTheApp :misc :pen :brush :sizer :font :cursor wxTAB_TRAVERSAL);
use Wx::Event qw(EVT_MOUSE_EVENTS EVT_PAINT EVT_ERASE_BACKGROUND EVT_SIZE); use Wx::Event qw(EVT_MOUSE_EVENTS EVT_PAINT EVT_ERASE_BACKGROUND EVT_SIZE);
use base 'Wx::Panel'; use base 'Wx::Panel';
use Wx::Locale gettext => 'L';
sub new { sub new {
my $class = shift; my $class = shift;
my ($parent, $size, $objects, $model, $config) = @_; my ($parent, $size, $objects, $model, $config) = @_;
@ -126,8 +128,8 @@ sub repaint {
$dc->SetFont(Wx::Font->new(14, wxDEFAULT, wxNORMAL, wxNORMAL)); $dc->SetFont(Wx::Font->new(14, wxDEFAULT, wxNORMAL, wxNORMAL));
$dc->DrawLabel( $dc->DrawLabel(
join('-', +(localtime)[3,4]) eq '13-8' join('-', +(localtime)[3,4]) eq '13-8'
? 'What do you want to print today? ™' # Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap. ? L('What do you want to print today? ™') # Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap.
: 'Drag your objects here', : L('Drag your objects here'),
Wx::Rect->new(0, 0, $self->GetSize->GetWidth, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); Wx::Rect->new(0, 0, $self->GetSize->GetWidth, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
} }

View File

@ -8,6 +8,8 @@ use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY);
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX); use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX);
use base qw(Wx::Panel Class::Accessor); use base qw(Wx::Panel Class::Accessor);
use Wx::Locale gettext => 'L';
__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom)); __PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
sub new { sub new {
@ -58,30 +60,42 @@ sub new {
$z_label_high->SetFont($Slic3r::GUI::small_font); $z_label_high->SetFont($Slic3r::GUI::small_font);
$self->single_layer(0); $self->single_layer(0);
my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, "1 Layer"); my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, L("1 Layer"));
my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, "View"); my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, L("View"));
my $choice_view_type = $self->{choice_view_type} = Wx::Choice->new($self, -1); my $choice_view_type = $self->{choice_view_type} = Wx::Choice->new($self, -1);
$choice_view_type->Append("Feature type"); $choice_view_type->Append(L("Feature type"));
$choice_view_type->Append("Height"); $choice_view_type->Append(L("Height"));
$choice_view_type->Append("Width"); $choice_view_type->Append(L("Width"));
$choice_view_type->Append("Speed"); $choice_view_type->Append(L("Speed"));
$choice_view_type->Append("Tool"); $choice_view_type->Append(L("Tool"));
$choice_view_type->SetSelection(0); $choice_view_type->SetSelection(0);
my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, "Show"); my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, L("Show"));
my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new(); my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new();
$combochecklist_features->Create($self, -1, "Feature types", wxDefaultPosition, [200, -1], wxCB_READONLY); $combochecklist_features->Create($self, -1, L("Feature types"), wxDefaultPosition, [200, -1], wxCB_READONLY);
my $feature_text = "Feature types"; my $feature_text = L("Feature types");
my $feature_items = "Perimeter|External perimeter|Overhang perimeter|Internal infill|Solid infill|Top solid infill|Bridge infill|Gap fill|Skirt|Support material|Support material interface|Wipe tower|Custom"; my $feature_items = L("Perimeter")."|"
.L("External perimeter")."|"
.L("Overhang perimeter")."|"
.L("Internal infill")."|"
.L("Solid infill")."|"
.L("Top solid infill")."|"
.L("Bridge infill")."|"
.L("Gap fill")."|"
.L("Skirt")."|"
.L("Support material")."|"
.L("Support material interface")."|"
.L("Wipe tower")."|"
.L("Custom");
Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1); Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1);
my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, "Travel"); my $checkbox_travel = $self->{checkbox_travel} = Wx::CheckBox->new($self, -1, L("Travel"));
my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, "Retractions"); my $checkbox_retractions = $self->{checkbox_retractions} = Wx::CheckBox->new($self, -1, L("Retractions"));
my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, "Unretractions"); my $checkbox_unretractions = $self->{checkbox_unretractions} = Wx::CheckBox->new($self, -1, L("Unretractions"));
my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, "Shells"); my $checkbox_shells = $self->{checkbox_shells} = Wx::CheckBox->new($self, -1, L("Shells"));
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
my $vsizer = Wx::BoxSizer->new(wxVERTICAL); my $vsizer = Wx::BoxSizer->new(wxVERTICAL);

View File

@ -1,6 +1,7 @@
#include "Analyzer.hpp" #include "Analyzer.hpp"
#include "PreviewData.hpp" #include "PreviewData.hpp"
#include <float.h> #include <float.h>
#include "slic3r/GUI/GUI.hpp"
namespace Slic3r { namespace Slic3r {
@ -132,21 +133,21 @@ const GCodePreviewData::Color GCodePreviewData::Extrusion::Default_Extrusion_Rol
// todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp // todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp
const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles] const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles]
{ {
"None", L("None"),
"Perimeter", L("Perimeter"),
"External perimeter", L("External perimeter"),
"Overhang perimeter", L("Overhang perimeter"),
"Internal infill", L("Internal infill"),
"Solid infill", L("Solid infill"),
"Top solid infill", L("Top solid infill"),
"Bridge infill", L("Bridge infill"),
"Gap fill", L("Gap fill"),
"Skirt", L("Skirt"),
"Support material", L("Support material"),
"Support material interface", L("Support material interface"),
"Wipe tower", L("Wipe tower"),
"Custom", L("Custom"),
"Mixed" L("Mixed")
}; };
const GCodePreviewData::Extrusion::EViewType GCodePreviewData::Extrusion::Default_View_Type = GCodePreviewData::Extrusion::FeatureType; const GCodePreviewData::Extrusion::EViewType GCodePreviewData::Extrusion::Default_View_Type = GCodePreviewData::Extrusion::FeatureType;
@ -325,15 +326,15 @@ std::string GCodePreviewData::get_legend_title() const
switch (extrusion.view_type) switch (extrusion.view_type)
{ {
case Extrusion::FeatureType: case Extrusion::FeatureType:
return "Feature type"; return L("Feature type");
case Extrusion::Height: case Extrusion::Height:
return "Height (mm)"; return L("Height (mm)");
case Extrusion::Width: case Extrusion::Width:
return "Width (mm)"; return L("Width (mm)");
case Extrusion::Feedrate: case Extrusion::Feedrate:
return "Speed (mm/s)"; return L("Speed (mm/s)");
case Extrusion::Tool: case Extrusion::Tool:
return "Tool"; return L("Tool");
} }
return ""; return "";

View File

@ -27,6 +27,8 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/settings.h> #include <wx/settings.h>
#include "GUI.hpp"
namespace Slic3r { namespace Slic3r {
void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh) void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh)
@ -1144,7 +1146,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
m_data.clear(); m_data.clear();
// collects items to render // collects items to render
const std::string& title = preview_data.get_legend_title(); auto title = GUI::L_str(preview_data.get_legend_title());
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors); const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
unsigned int items_count = (unsigned int)items.size(); unsigned int items_count = (unsigned int)items.size();
@ -1166,7 +1168,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
unsigned int max_text_height = 0; unsigned int max_text_height = 0;
for (const GCodePreviewData::LegendItem& item : items) for (const GCodePreviewData::LegendItem& item : items)
{ {
memDC.GetTextExtent(item.text, &w, &h); memDC.GetTextExtent(GUI::L_str(item.text), &w, &h);
max_text_width = std::max(max_text_width, (unsigned int)w); max_text_width = std::max(max_text_width, (unsigned int)w);
max_text_height = std::max(max_text_height, (unsigned int)h); max_text_height = std::max(max_text_height, (unsigned int)h);
} }
@ -1243,7 +1245,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square)); memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square));
// draw text // draw text
memDC.DrawText(item.text, text_x, icon_y + text_y_offset); memDC.DrawText(GUI::L_str(item.text), text_x, icon_y + text_y_offset);
// update y // update y
icon_y += icon_y_step; icon_y += icon_y_step;

View File

@ -531,7 +531,7 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
for (const std::string& item : items_str) for (const std::string& item : items_str)
{ {
popup->Append(item); popup->Append(from_u8(item));
} }
for (unsigned int i = 0; i < popup->GetCount(); ++i) for (unsigned int i = 0; i < popup->GetCount(); ++i)