Unified usage of localization macros in slic3r/libslic3r

This commit is contained in:
YuSanka 2023-03-20 10:38:34 +01:00 committed by Lukas Matena
parent 9cb50e6586
commit 19f2a1d9e9
44 changed files with 211 additions and 264 deletions

View file

@ -27,8 +27,6 @@
#include <boost/log/trivial.hpp>
#include <boost/regex.hpp>
// Mark string for localization and translate.
#define L(s) Slic3r::I18N::translate(s)
namespace Slic3r {
@ -474,20 +472,20 @@ std::string Print::validate(std::string* warning) const
std::vector<unsigned int> extruders = this->extruders();
if (m_objects.empty())
return L("All objects are outside of the print volume.");
return _u8L("All objects are outside of the print volume.");
if (extruders.empty())
return L("The supplied settings will cause an empty print.");
return _u8L("The supplied settings will cause an empty print.");
if (m_config.complete_objects) {
if (! sequential_print_horizontal_clearance_valid(*this))
return L("Some objects are too close; your extruder will collide with them.");
return _u8L("Some objects are too close; your extruder will collide with them.");
if (! sequential_print_vertical_clearance_valid(*this))
return L("Some objects are too tall and cannot be printed without extruder collisions.");
return _u8L("Some objects are too tall and cannot be printed without extruder collisions.");
}
if (m_config.avoid_crossing_perimeters && m_config.avoid_crossing_curled_overhangs) {
return L("Avoid crossing perimeters option and avoid crossing curled overhangs option cannot be both enabled together.");
return _u8L("Avoid crossing perimeters option and avoid crossing curled overhangs option cannot be both enabled together.");
}
if (m_config.spiral_vase) {
@ -496,11 +494,11 @@ std::string Print::validate(std::string* warning) const
total_copies_count += object->instances().size();
// #4043
if (total_copies_count > 1 && ! m_config.complete_objects.value)
return L("Only a single object may be printed at a time in Spiral Vase mode. "
return _u8L("Only a single object may be printed at a time in Spiral Vase mode. "
"Either remove all but the last object, or enable sequential mode by \"complete_objects\".");
assert(m_objects.size() == 1);
if (m_objects.front()->all_regions().size() > 1)
return L("The Spiral Vase option can only be used when printing single material objects.");
return _u8L("The Spiral Vase option can only be used when printing single material objects.");
}
// Cache of layer height profiles for checking:
@ -524,7 +522,7 @@ std::string Print::validate(std::string* warning) const
//FIXME It is quite expensive to generate object layers just to get the print height!
if (auto layers = generate_object_layers(print_object.slicing_parameters(), layer_height_profile(print_object_idx));
! layers.empty() && layers.back() > this->config().max_print_height + EPSILON) {
return L("The print is taller than the maximum allowed height. You might want to reduce the size of your model"
return _u8L("The print is taller than the maximum allowed height. You might want to reduce the size of your model"
" or change current print settings and retry.");
}
}
@ -541,7 +539,7 @@ std::string Print::validate(std::string* warning) const
print_object.model_object()->has_custom_layering()) {
if (const std::vector<coordf_t> &layers = layer_height_profile(print_object_idx); ! layers.empty())
if (! check_object_layers_fixed(print_object.slicing_parameters(), layers))
return L("Variable layer height is not supported with Organic supports.");
return _u8L("Variable layer height is not supported with Organic supports.");
}
if (this->has_wipe_tower() && ! m_objects.empty()) {
@ -554,21 +552,21 @@ std::string Print::validate(std::string* warning) const
double filament_diam = m_config.filament_diameter.get_at(extruder_idx);
if (nozzle_diam - EPSILON > first_nozzle_diam || nozzle_diam + EPSILON < first_nozzle_diam
|| std::abs((filament_diam-first_filament_diam)/first_filament_diam) > 0.1)
return L("The wipe tower is only supported if all extruders have the same nozzle diameter "
return _u8L("The wipe tower is only supported if all extruders have the same nozzle diameter "
"and use filaments of the same diameter.");
}
if (m_config.gcode_flavor != gcfRepRapSprinter && m_config.gcode_flavor != gcfRepRapFirmware &&
m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlinLegacy && m_config.gcode_flavor != gcfMarlinFirmware)
return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter, RepRapFirmware and Repetier G-code flavors.");
return _u8L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter, RepRapFirmware and Repetier G-code flavors.");
if (! m_config.use_relative_e_distances)
return L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).");
return _u8L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).");
if (m_config.ooze_prevention && m_config.single_extruder_multi_material)
return L("Ooze prevention is only supported with the wipe tower when 'single_extruder_multi_material' is off.");
return _u8L("Ooze prevention is only supported with the wipe tower when 'single_extruder_multi_material' is off.");
if (m_config.use_volumetric_e)
return L("The Wipe Tower currently does not support volumetric E (use_volumetric_e=0).");
return _u8L("The Wipe Tower currently does not support volumetric E (use_volumetric_e=0).");
if (m_config.complete_objects && extruders.size() > 1)
return L("The Wipe Tower is currently not supported for multimaterial sequential prints.");
return _u8L("The Wipe Tower is currently not supported for multimaterial sequential prints.");
if (m_objects.size() > 1) {
const SlicingParameters &slicing_params0 = m_objects.front()->slicing_parameters();
@ -578,14 +576,14 @@ std::string Print::validate(std::string* warning) const
const SlicingParameters &slicing_params = object->slicing_parameters();
if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON ||
std::abs(slicing_params.layer_height - slicing_params0.layer_height ) > EPSILON)
return L("The Wipe Tower is only supported for multiple objects if they have equal layer heights");
return _u8L("The Wipe Tower is only supported for multiple objects if they have equal layer heights");
if (slicing_params.raft_layers() != slicing_params0.raft_layers())
return L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers");
return _u8L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers");
if (slicing_params0.gap_object_support != slicing_params.gap_object_support ||
slicing_params0.gap_support_object != slicing_params.gap_support_object)
return L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance");
return _u8L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance");
if (! equal_layering(slicing_params, slicing_params0))
return L("The Wipe Tower is only supported for multiple objects if they are sliced equally.");
return _u8L("The Wipe Tower is only supported for multiple objects if they are sliced equally.");
if (has_custom_layering) {
auto &lh = layer_height_profile(i);
auto &lh_tallest = layer_height_profile(tallest_object_idx);
@ -610,7 +608,7 @@ std::string Print::validate(std::string* warning) const
if (i%2 == 0 && layer_height_profiles[tallest_object_idx][i] > layer_height_profiles[idx_object][layer_height_profiles[idx_object].size() - 2 ])
break;
if (std::abs(layer_height_profiles[idx_object][i] - layer_height_profiles[tallest_object_idx][i]) > eps)
return L("The Wipe tower is only supported if all objects have the same variable layer height");
return _u8L("The Wipe tower is only supported if all objects have the same variable layer height");
++i;
}
}
@ -634,7 +632,7 @@ std::string Print::validate(std::string* warning) const
unsigned int total_extruders_count = m_config.nozzle_diameter.size();
for (const auto& extruder_idx : extruders)
if ( extruder_idx >= total_extruders_count )
return L("One or more object were assigned an extruder that the printer does not have.");
return _u8L("One or more object were assigned an extruder that the printer does not have.");
#endif
auto validate_extrusion_width = [/*min_nozzle_diameter,*/ max_nozzle_diameter](const ConfigBase &config, const char *opt_key, double layer_height, std::string &err_msg) -> bool {
@ -647,10 +645,10 @@ std::string Print::validate(std::string* warning) const
if (extrusion_width_min == 0) {
// Default "auto-generated" extrusion width is always valid.
} else if (extrusion_width_min <= layer_height) {
err_msg = (boost::format(L("%1%=%2% mm is too low to be printable at a layer height %3% mm")) % opt_key % extrusion_width_min % layer_height).str();
err_msg = (boost::format(_u8L("%1%=%2% mm is too low to be printable at a layer height %3% mm")) % opt_key % extrusion_width_min % layer_height).str();
return false;
} else if (extrusion_width_max >= max_nozzle_diameter * 3.) {
err_msg = (boost::format(L("Excessive %1%=%2% mm to be printable with a nozzle diameter %3% mm")) % opt_key % extrusion_width_max % max_nozzle_diameter).str();
err_msg = (boost::format(_u8L("Excessive %1%=%2% mm to be printable with a nozzle diameter %3% mm")) % opt_key % extrusion_width_max % max_nozzle_diameter).str();
return false;
}
return true;
@ -661,7 +659,7 @@ std::string Print::validate(std::string* warning) const
// The object has some form of support and either support_material_extruder or support_material_interface_extruder
// will be printed with the current tool without a forced tool change. Play safe, assert that all object nozzles
// are of the same diameter.
return L("Printing with multiple extruders of differing nozzle diameters. "
return _u8L("Printing with multiple extruders of differing nozzle diameters. "
"If support is to be printed with the current extruder (support_material_extruder == 0 or support_material_interface_extruder == 0), "
"all nozzles have to be of the same diameter.");
}
@ -669,11 +667,11 @@ std::string Print::validate(std::string* warning) const
if (object->config().support_material_contact_distance == 0) {
// Soluble interface
if (! object->config().support_material_synchronize_layers)
return L("For the Wipe Tower to work with the soluble supports, the support layers need to be synchronized with the object layers.");
return _u8L("For the Wipe Tower to work with the soluble supports, the support layers need to be synchronized with the object layers.");
} else {
// Non-soluble interface
if (object->config().support_material_extruder != 0 || object->config().support_material_interface_extruder != 0)
return L("The Wipe Tower currently supports the non-soluble supports only if they are printed with the current extruder without triggering a tool change. "
return _u8L("The Wipe Tower currently supports the non-soluble supports only if they are printed with the current extruder without triggering a tool change. "
"(both support_material_extruder and support_material_interface_extruder need to be set to 0).");
}
}
@ -709,12 +707,12 @@ std::string Print::validate(std::string* warning) const
first_layer_min_nozzle_diameter = min_nozzle_diameter;
}
if (first_layer_height > first_layer_min_nozzle_diameter)
return L("First layer height can't be greater than nozzle diameter");
return _u8L("First layer height can't be greater than nozzle diameter");
// validate layer_height
double layer_height = object->config().layer_height.value;
if (layer_height > min_nozzle_diameter)
return L("Layer height can't be greater than nozzle diameter");
return _u8L("Layer height can't be greater than nozzle diameter");
// Validate extrusion widths.
std::string err_msg;
@ -735,11 +733,11 @@ std::string Print::validate(std::string* warning) const
// See GH issues #6336 #5073
if ((m_config.gcode_flavor == gcfMarlinLegacy || m_config.gcode_flavor == gcfMarlinFirmware) &&
! before_layer_gcode_resets_extruder && ! layer_gcode_resets_extruder)
return L("Relative extruder addressing requires resetting the extruder position at each layer to prevent loss of floating point accuracy. Add \"G92 E0\" to layer_gcode.");
return _u8L("Relative extruder addressing requires resetting the extruder position at each layer to prevent loss of floating point accuracy. Add \"G92 E0\" to layer_gcode.");
} else if (before_layer_gcode_resets_extruder)
return L("\"G92 E0\" was found in before_layer_gcode, which is incompatible with absolute extruder addressing.");
return _u8L("\"G92 E0\" was found in before_layer_gcode, which is incompatible with absolute extruder addressing.");
else if (layer_gcode_resets_extruder)
return L("\"G92 E0\" was found in layer_gcode, which is incompatible with absolute extruder addressing.");
return _u8L("\"G92 E0\" was found in layer_gcode, which is incompatible with absolute extruder addressing.");
}
return std::string();
@ -881,7 +879,7 @@ void Print::process()
BOOST_LOG_TRIVIAL(info) << "Starting the slicing process." << log_memory_info();
for (PrintObject *obj : m_objects)
obj->make_perimeters();
this->set_status(70, L("Infilling layers"));
this->set_status(70, _u8L("Infilling layers"));
for (PrintObject *obj : m_objects)
obj->infill();
for (PrintObject *obj : m_objects)
@ -898,7 +896,7 @@ void Print::process()
m_wipe_tower_data.clear();
m_tool_ordering.clear();
if (this->has_wipe_tower()) {
//this->set_status(95, L("Generating wipe tower"));
//this->set_status(95, _u8L("Generating wipe tower"));
this->_make_wipe_tower();
} else if (! this->config().complete_objects.value) {
// Initialize the tool ordering, so it could be used by the G-code preview slider for planning tool changes and filament switches.
@ -909,7 +907,7 @@ void Print::process()
this->set_done(psWipeTower);
}
if (this->set_started(psSkirtBrim)) {
this->set_status(88, L("Generating skirt and brim"));
this->set_status(88, _u8L("Generating skirt and brim"));
m_skirt.clear();
m_skirt_convex_hull.clear();
@ -957,11 +955,11 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
std::string message;
if (!path.empty() && result == nullptr) {
// Only show the path if preview_data is not set -> running from command line.
message = L("Exporting G-code");
message = _u8L("Exporting G-code");
message += " to ";
message += path;
} else
message = L("Generating G-code");
message = _u8L("Generating G-code");
this->set_status(90, message);
// Create GCode on heap, it has quite a lot of data.
@ -1181,30 +1179,30 @@ void Print::alert_when_supports_needed()
{
if (this->set_started(psAlertWhenSupportsNeeded)) {
BOOST_LOG_TRIVIAL(debug) << "psAlertWhenSupportsNeeded - start";
set_status(69, L("Alert if supports needed"));
set_status(69, _u8L("Alert if supports needed"));
auto issue_to_alert_message = [](SupportSpotsGenerator::SupportPointCause cause, bool critical) {
std::string message;
switch (cause) {
//TRN Alert when support is needed. Describes that the model has long bridging extrusions which may print badly
case SupportSpotsGenerator::SupportPointCause::LongBridge: message = L("Long bridging extrusions"); break;
case SupportSpotsGenerator::SupportPointCause::LongBridge: message = _u8L("Long bridging extrusions"); break;
//TRN Alert when support is needed. Describes bridge anchors/turns in the air, which will definitely print badly
case SupportSpotsGenerator::SupportPointCause::FloatingBridgeAnchor: message = L("Floating bridge anchors"); break;
case SupportSpotsGenerator::SupportPointCause::FloatingBridgeAnchor: message = _u8L("Floating bridge anchors"); break;
case SupportSpotsGenerator::SupportPointCause::FloatingExtrusion:
if (critical) {
//TRN Alert when support is needed. Describes that the print has large overhang area which will print badly or not print at all.
message = L("Collapsing overhang");
message = _u8L("Collapsing overhang");
} else {
//TRN Alert when support is needed. Describes extrusions that are not supported enough and come out curled or loose.
message = L("Loose extrusions");
message = _u8L("Loose extrusions");
}
break;
//TRN Alert when support is needed. Describes that the print has low bed adhesion and may became loose.
case SupportSpotsGenerator::SupportPointCause::SeparationFromBed: message = L("Low bed adhesion"); break;
case SupportSpotsGenerator::SupportPointCause::SeparationFromBed: message = _u8L("Low bed adhesion"); break;
//TRN Alert when support is needed. Describes that the object has part that is not connected to the bed and will not print at all without supports.
case SupportSpotsGenerator::SupportPointCause::UnstableFloatingPart: message = L("Floating object part"); break;
case SupportSpotsGenerator::SupportPointCause::UnstableFloatingPart: message = _u8L("Floating object part"); break;
//TRN Alert when support is needed. Describes that the object has thin part that may brake during printing
case SupportSpotsGenerator::SupportPointCause::WeakObjectPart: message = L("Thin fragile part"); break;
case SupportSpotsGenerator::SupportPointCause::WeakObjectPart: message = _u8L("Thin fragile part"); break;
}
return message;
@ -1312,13 +1310,13 @@ void Print::alert_when_supports_needed()
}
lines.push_back("");
lines.push_back(L("Consider enabling supports."));
lines.push_back(_u8L("Consider enabling supports."));
if (recommend_brim) {
lines.push_back(L("Also consider enabling brim."));
lines.push_back(_u8L("Also consider enabling brim."));
}
// TRN Alert message for detected print issues. first argument is a list of detected issues.
auto message = Slic3r::format(L("Detected print stability issues:\n%1%"), elements_to_translated_list(lines, multiline_list_rule));
auto message = Slic3r::format(_u8L("Detected print stability issues:\n%1%"), elements_to_translated_list(lines, multiline_list_rule));
if (objects_isssues.size() > 0) {
this->active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL, message);