[glom] Use Glib::ustring::compose() instead of concatenation for translatable strings.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Use Glib::ustring::compose() instead of concatenation for translatable strings.
- Date: Thu, 13 Oct 2011 17:56:51 +0000 (UTC)
commit b0a17083b7a31e68b52fefc6f97d728c34b60b9e
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Oct 13 19:11:40 2011 +0200
Use Glib::ustring::compose() instead of concatenation for translatable strings.
* glom/bakery/dialog_offersave.cc:
* glom/import_csv/dialog_import_csv.cc:
* glom/mode_design/fields/dialog_fieldcalculation.cc:
* glom/mode_design/layout/combobox_relationship.cc:
* glom/mode_design/layout/dialog_layout_details.cc:
* glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
* glom/navigation/box_tables.cc:
* glom/utils_ui.cc: Let translators arrange built strings.
ChangeLog | 13 +++++++++++++
glom/bakery/dialog_offersave.cc | 6 +++++-
glom/import_csv/dialog_import_csv.cc | 2 +-
glom/mode_design/fields/dialog_fieldcalculation.cc | 4 ++--
glom/mode_design/layout/combobox_relationship.cc | 4 ++--
glom/mode_design/layout/dialog_layout_details.cc | 6 +++---
.../layout_item_dialogs/dialog_buttonscript.cc | 2 +-
glom/navigation/box_tables.cc | 4 ++--
glom/utils_ui.cc | 2 +-
9 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 23dc405..461caf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-10-13 Murray Cumming <murrayc murrayc com>
+
+ Use Glib::ustring::compose() instead of concatenation for translatable strings.
+
+ * glom/bakery/dialog_offersave.cc:
+ * glom/import_csv/dialog_import_csv.cc:
+ * glom/mode_design/fields/dialog_fieldcalculation.cc:
+ * glom/mode_design/layout/combobox_relationship.cc:
+ * glom/mode_design/layout/dialog_layout_details.cc:
+ * glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
+ * glom/navigation/box_tables.cc:
+ * glom/utils_ui.cc: Let translators arrange built strings.
+
2011-10-13 Ben Konrath <ben bagu org>
Add example document to test field formatting.
diff --git a/glom/bakery/dialog_offersave.cc b/glom/bakery/dialog_offersave.cc
index 3a83176..de9db86 100644
--- a/glom/bakery/dialog_offersave.cc
+++ b/glom/bakery/dialog_offersave.cc
@@ -29,7 +29,11 @@ namespace
{
Glib::ustring message = _("This document has unsaved changes. Would you like to save the document?");
if(!file_uri.empty())
- message += _("\n\nDocument:\n") + Glib::filename_display_basename(file_uri); //TODO: Can we use filename_display_basename() with a URI?
+ {
+ message += "\n\n";
+ message += Glib::ustring::compose(_("Document:\n%1"), Glib::filename_display_basename(file_uri)); //TODO: Can we use filename_display_basename() with a URI?
+ }
+
return message;
}
}
diff --git a/glom/import_csv/dialog_import_csv.cc b/glom/import_csv/dialog_import_csv.cc
index 378d978..55df800 100644
--- a/glom/import_csv/dialog_import_csv.cc
+++ b/glom/import_csv/dialog_import_csv.cc
@@ -739,7 +739,7 @@ void Dialog_Import_CSV::on_parser_file_read_error(const Glib::ustring& error_mes
void Dialog_Import_CSV::on_parser_have_display_name(const Glib::ustring& display_name)
{
- set_title(_("Import From CSV File: ") + display_name);
+ set_title( Glib::ustring::compose(_("Import From CSV File: %1"), display_name) );
}
void Dialog_Import_CSV::on_parser_state_changed()
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.cc b/glom/mode_design/fields/dialog_fieldcalculation.cc
index 24cf4fc..8a4a848 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -141,9 +141,9 @@ void Dialog_FieldCalculation::on_button_test()
error_message);
if(error_message.empty())
- Utils::show_ok_dialog(_("Calculation result"), _("The result of the calculation is:\n") + value.to_string(), *this, Gtk::MESSAGE_INFO);
+ Utils::show_ok_dialog(_("Calculation result"), Glib::ustring::compose(_("The result of the calculation is:\n%1"), value.to_string()), *this, Gtk::MESSAGE_INFO);
else
- Utils::show_ok_dialog(_("Calculation failed"), _("The calculation failed with this error:\n") + error_message, *this, Gtk::MESSAGE_ERROR);
+ Utils::show_ok_dialog( _("Calculation failed"), Glib::ustring::compose(_("The calculation failed with this error:\n%s"), error_message), *this, Gtk::MESSAGE_ERROR);
//Show what fields would trigger the recalculation:
sharedptr<Field> temp = sharedptr<Field>::create();
diff --git a/glom/mode_design/layout/combobox_relationship.cc b/glom/mode_design/layout/combobox_relationship.cc
index 95dd983..1604836 100644
--- a/glom/mode_design/layout/combobox_relationship.cc
+++ b/glom/mode_design/layout/combobox_relationship.cc
@@ -264,11 +264,11 @@ void ComboBox_Relationship::on_cell_data_fromfield(const Gtk::TreeModel::const_i
{
sharedptr<Relationship> parent_relationship = (*iterParent)[m_model_columns.m_relationship];
if(parent_relationship)
- m_renderer_fromfield->set_property("text", _(" Via: ") + parent_relationship->get_title() + "::" + relationship->get_from_field());
+ m_renderer_fromfield->set_property("text", Glib::ustring::compose(_(" Via: %1::%2"), parent_relationship->get_title(), relationship->get_from_field()));
}
else
{
- m_renderer_fromfield->set_property("text", _(" Via: ") + relationship->get_to_field());
+ m_renderer_fromfield->set_property("text", Glib::ustring::compose(_(" Via: %1"), relationship->get_to_field()));
}
}
else
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index 0d103b0..143c9ab 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -1118,9 +1118,9 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
{
sharedptr<LayoutItem_CalendarPortal> layout_calendar = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(layout_portal);
if(layout_calendar)
- markup = _("Related Calendar: ") + layout_portal->get_relationship_name();
+ markup = Glib::ustring::compose(_("Related Calendar: %1"), layout_portal->get_relationship_name());
else
- markup = _("Related List: ") + layout_portal->get_relationship_name();
+ markup = Glib::ustring::compose(_("Related List: %1"), layout_portal->get_relationship_name());
}
else
{
@@ -1137,7 +1137,7 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
sharedptr<LayoutItem_Field> layout_item_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
if(layout_item_field)
{
- markup = _("Field: ") + layout_item_field->get_layout_display_name(); //TODO: Put this all in a sprintf-style string so it can be translated properly.
+ markup = Glib::ustring::compose(_("Field: %1"), layout_item_field->get_layout_display_name());
//Just for debugging:
//if(!row[m_model_items->m_columns.m_col_editable])
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
index 546afa6..f5b285c 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
@@ -134,7 +134,7 @@ void Dialog_ButtonScript::on_button_test_script()
error_message);
if(!error_message.empty())
- Utils::show_ok_dialog(_("Calculation failed"), _("The calculation failed with this error:\n") + error_message, *this, Gtk::MESSAGE_ERROR);
+ Utils::show_ok_dialog(_("Calculation failed"), Glib::ustring::compose(_("The calculation failed with this error:\n%1"), error_message), *this, Gtk::MESSAGE_ERROR);
}
} //namespace Glom
diff --git a/glom/navigation/box_tables.cc b/glom/navigation/box_tables.cc
index 361c6a6..a40c6fd 100644
--- a/glom/navigation/box_tables.cc
+++ b/glom/navigation/box_tables.cc
@@ -300,11 +300,11 @@ void Box_Tables::on_adddel_Delete(const Gtk::TreeModel::iterator& rowStart, cons
else
{
//Ask the user to confirm:
- Glib::ustring strMsg = _("Are you sure that you want to delete this table?\nTable name: ") + table_name;
+ const Glib::ustring strMsg = Glib::ustring::compose(_("Are you sure that you want to delete this table?\nTable name: %1"), table_name);
Gtk::MessageDialog dialog(Utils::bold_message(_("Delete Table")), true);
dialog.set_secondary_text(strMsg);
dialog.set_transient_for(*Application::get_application());
- int iButtonClicked = dialog.run();
+ const int iButtonClicked = dialog.run();
//Delete the table:
if(iButtonClicked == Gtk::RESPONSE_OK)
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index e595486..38d5dfe 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -148,7 +148,7 @@ void Utils::show_help(const Glib::ustring& id)
}
catch(const std::exception& ex)
{
- const Glib::ustring message = _("Could not display help: ") + Glib::ustring(ex.what());
+ const Glib::ustring message = Glib::ustring::compose(_("Could not display help: %1"), Glib::ustring(ex.what()));
Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR);
dialog.run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]