[glom] TranslatableItem: Require the caller to provide the locale.



commit b1d8044f8efa6f41ba4c9bf37aae54a192200ebc
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jan 16 09:03:33 2012 +0100

    TranslatableItem: Require the caller to provide the locale.
    
    * glom/libglom/data_structure/translatable_item.[h|cc]:
    get_current_locale(), set_current_locale(), set_original_locale(),
    get_current_locale_not_original(): Move to Glom::Application, out of
    libglom.
    get_title(), set_title(), get_title_or_name(): Add a ustring locale
    parameter.
    Added virtual get_title_original(), get_title_translation(),
    get_title_or_name_original(), get_title_or_name_translation().
    Added set_title_original() and set_title_translation(), though these
    are private and non-virtual.
    This let use discover the actual original text and its translations
    while still using get_title(locale) to just get the title that should
    be used. Before we could get the exact entered title for a locale just
    by setting the current locale.
    * libglom/data_structure/layout/layoutitem_field.[h|cc]: Override the
    new virtual methods.
    * Many other files: Adapt.
    
    This allows us to use different translatations from Online Glom, which
    only loads the library once for all Glom files. And this is generally
    cleaner, even if it requires more repetitive code.

 ChangeLog                                          |   26 ++++++++++++++++++++
 glom/application.cc                                |    2 +-
 .../data_structure/layout/layoutitem_portal.h      |    4 +-
 .../layout/report_parts/layoutitem_fieldsummary.h  |    4 +-
 4 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b031994..a6f74ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2012-01-16  Murray Cumming  <murrayc murrayc com>
+
+	TranslatableItem: Require the caller to provide the locale.
+
+	* glom/libglom/data_structure/translatable_item.[h|cc]:
+	get_current_locale(), set_current_locale(), set_original_locale(),
+	get_current_locale_not_original(): Move to Glom::Application, out of 
+	libglom.
+	get_title(), set_title(), get_title_or_name(): Add a ustring locale 
+	parameter.
+	Added virtual get_title_original(), get_title_translation(), 
+	get_title_or_name_original(), get_title_or_name_translation().
+	Added set_title_original() and set_title_translation(), though these
+	are private and non-virtual.
+	This let use discover the actual original text and its translations
+	while still using get_title(locale) to just get the title that should
+	be used. Before we could get the exact entered title for a locale just
+	by setting the current locale.
+	* libglom/data_structure/layout/layoutitem_field.[h|cc]: Override the 
+	new virtual methods.
+	* Many other files: Adapt.
+
+	This allows us to use different translatations from Online Glom, which 
+	only loads the library once for all Glom files. And this is generally 
+	cleaner, even if it requires more repetitive code.
+
 2012-01-13  Murray Cumming  <murrayc murrayc com>
 
 	test_document_load_translations: Test title_singular too.
diff --git a/glom/application.cc b/glom/application.cc
index 9b6379f..c0820e3 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -2875,7 +2875,7 @@ Glib::ustring Application::get_original_locale()
   return m_original_locale; 
 }
 
-bool Application::get_current_locale_not_original() //TODO: Make this const?
+bool Application::get_current_locale_not_original()
 {
   if(m_original_locale.empty())
     get_original_locale();
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.h b/glom/libglom/data_structure/layout/layoutitem_portal.h
index 793ec5e..68cd2b0 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.h
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.h
@@ -48,9 +48,9 @@ public:
   virtual LayoutItem* clone() const;
 
   virtual Glib::ustring get_title(const Glib::ustring& locale) const;
-  //TODO: get_title_original() and get_title_translation()?
+  //TODO: get_title_original() and get_title_translation()? But this just uses the Relationship title anyway.
   virtual Glib::ustring get_title_or_name(const Glib::ustring& locale) const;
-  //TODO: get_title_or_name_original()?
+  //TODO: get_title_or_name_original()? But this just uses the Relationship title anyway.
   virtual Glib::ustring get_part_type_name() const;
 
   virtual void change_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name, const Glib::ustring& field_name_new);
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
index 2d02943..b8164d4 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h
@@ -62,9 +62,9 @@ public:
   void set_field(const sharedptr<LayoutItem_Field>& field);
 
   virtual Glib::ustring get_title(const Glib::ustring& locale) const;
-  //TODO: get_title_original() and get_title_translation():
+  //TODO: get_title_original() and get_title_translation(): But this just uses the field title anyway.
   virtual Glib::ustring get_title_or_name(const Glib::ustring& locale) const;
-  //TODO: get_title_or_name_original()?
+  //TODO: get_title_or_name_original()? But this just uses the field title anyway.
 
   virtual Glib::ustring get_layout_display_name() const;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]