libglom-1.32  1.32.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Glom::TranslatableItem Class Reference

TranslatableItem have a map of translation strings - one string for each locale. More...

Inheritance diagram for Glom::TranslatableItem:
Inheritance graph
[legend]

Public Types

enum  enumTranslatableItemType {
  enumTranslatableItemType::INVALID,
  enumTranslatableItemType::FIELD,
  enumTranslatableItemType::RELATIONSHIP,
  enumTranslatableItemType::LAYOUT_ITEM,
  enumTranslatableItemType::CUSTOM_TITLE,
  enumTranslatableItemType::PRINT_LAYOUT,
  enumTranslatableItemType::REPORT,
  enumTranslatableItemType::TABLE,
  enumTranslatableItemType::BUTTON,
  enumTranslatableItemType::TEXTOBJECT,
  enumTranslatableItemType::IMAGEOBJECT,
  enumTranslatableItemType::CHOICEVALUE,
  enumTranslatableItemType::DATABASE_TITLE,
  enumTranslatableItemType::STATIC_TEXT
}
 
typedef std::unordered_map< Glib::ustring, Glib::ustring, std::hash< std::string > > type_map_locale_to_translations
 

Public Member Functions

 TranslatableItem () noexcept
 
 TranslatableItem (const TranslatableItem& src)=default
 
 TranslatableItem (TranslatableItem&& src)=default
 
virtual ~TranslatableItem ()=default
 
TranslatableItemoperator= (const TranslatableItem& src)=default
 
TranslatableItemoperator= (TranslatableItem&& src)=default
 
bool operator== (const TranslatableItem& src) const noexcept
 
bool operator!= (const TranslatableItem& src) const noexcept
 
virtual void set_name (const Glib::ustring& name) noexcept
 Set the non-translated identifier name. More...
 
virtual Glib::ustring get_name () const noexcept
 Get the non-translated identifier name. More...
 
bool get_name_not_empty () const noexcept
 
virtual Glib::ustring get_title_or_name (const Glib::ustring& locale) const noexcept
 
virtual Glib::ustring get_title (const Glib::ustring& locale) const noexcept
 Get the title's translation for the specified locale, falling back to the original text if there is no translation. More...
 
virtual Glib::ustring get_title_original () const noexcept
 Get the title's original (non-translated, usually English) text. More...
 
Glib::ustring get_title_translation (const Glib::ustring& locale, bool fallback=true) const noexcept
 Get the title's translation for the specified locale, optionally falling back to a locale of the same language, and then falling back to the original. More...
 
void set_title (const Glib::ustring& title, const Glib::ustring& locale) noexcept
 Set the title's translation for the specified locale. More...
 
void set_title_original (const Glib::ustring& title) noexcept
 Set the title's original (non-translated, usually English) text. More...
 
void clear_title_in_all_locales () noexcept
 Clear the original title and any translations of the title. More...
 
bool get_has_translations () const noexcept
 
enumTranslatableItemType get_translatable_item_type () const noexcept
 

Static Public Member Functions

static Glib::ustring get_translatable_type_name (enumTranslatableItemType item_type) noexcept
 
static Glib::ustring get_translatable_type_name_nontranslated (enumTranslatableItemType item_type) noexcept
 The non-translated name is used for the context in gettext .po files. More...
 

Protected Attributes

enumTranslatableItemType m_translatable_item_type
 

Detailed Description

TranslatableItem have a map of translation strings - one string for each locale.

Member Typedef Documentation

◆ type_map_locale_to_translations

Member Enumeration Documentation

◆ enumTranslatableItemType

Enumerator
INVALID 
FIELD 
RELATIONSHIP 
LAYOUT_ITEM 
CUSTOM_TITLE 
PRINT_LAYOUT 
REPORT 
TABLE 
BUTTON 
TEXTOBJECT 
IMAGEOBJECT 
CHOICEVALUE 
DATABASE_TITLE 
STATIC_TEXT 

Constructor & Destructor Documentation

◆ TranslatableItem() [1/3]

Glom::TranslatableItem::TranslatableItem ( )
noexcept

◆ TranslatableItem() [2/3]

Glom::TranslatableItem::TranslatableItem ( const TranslatableItem src)
default

◆ TranslatableItem() [3/3]

Glom::TranslatableItem::TranslatableItem ( TranslatableItem&&  src)
default

◆ ~TranslatableItem()

virtual Glom::TranslatableItem::~TranslatableItem ( )
virtualdefault

Member Function Documentation

◆ clear_title_in_all_locales()

void Glom::TranslatableItem::clear_title_in_all_locales ( )
noexcept

Clear the original title and any translations of the title.

◆ get_has_translations()

bool Glom::TranslatableItem::get_has_translations ( ) const
noexcept

◆ get_name()

virtual Glib::ustring Glom::TranslatableItem::get_name ( ) const
virtualnoexcept

Get the non-translated identifier name.

Reimplemented in Glom::Field, and Glom::LayoutItem_Field.

◆ get_name_not_empty()

bool Glom::TranslatableItem::get_name_not_empty ( ) const
noexcept

◆ get_title()

virtual Glib::ustring Glom::TranslatableItem::get_title ( const Glib::ustring locale) const
virtualnoexcept

Get the title's translation for the specified locale, falling back to the original text if there is no translation.

See also get_title_translation() and get_title_original(), which (optionally) do not use fallbacks.

Parameters
localeThe locale whose title text should be returned. If this is empty then the original text will be returned.
Returns
The text of the title.

Reimplemented in Glom::LayoutItem_Field, Glom::LayoutItem_FieldSummary, and Glom::LayoutItem_Portal.

◆ get_title_or_name()

virtual Glib::ustring Glom::TranslatableItem::get_title_or_name ( const Glib::ustring locale) const
virtualnoexcept

◆ get_title_original()

virtual Glib::ustring Glom::TranslatableItem::get_title_original ( ) const
virtualnoexcept

Get the title's original (non-translated, usually English) text.

Reimplemented in Glom::ChoiceValue.

◆ get_title_translation()

Glib::ustring Glom::TranslatableItem::get_title_translation ( const Glib::ustring locale,
bool  fallback = true 
) const
noexcept

Get the title's translation for the specified locale, optionally falling back to a locale of the same language, and then falling back to the original.

Calling this with the current locale is the same as calling get_title_original().

◆ get_translatable_item_type()

enumTranslatableItemType Glom::TranslatableItem::get_translatable_item_type ( ) const
noexcept

◆ get_translatable_type_name()

static Glib::ustring Glom::TranslatableItem::get_translatable_type_name ( enumTranslatableItemType  item_type)
staticnoexcept

◆ get_translatable_type_name_nontranslated()

static Glib::ustring Glom::TranslatableItem::get_translatable_type_name_nontranslated ( enumTranslatableItemType  item_type)
staticnoexcept

The non-translated name is used for the context in gettext .po files.

◆ operator!=()

bool Glom::TranslatableItem::operator!= ( const TranslatableItem src) const
noexcept

◆ operator=() [1/2]

TranslatableItem& Glom::TranslatableItem::operator= ( const TranslatableItem src)
default

◆ operator=() [2/2]

TranslatableItem& Glom::TranslatableItem::operator= ( TranslatableItem&&  src)
default

◆ operator==()

bool Glom::TranslatableItem::operator== ( const TranslatableItem src) const
noexcept

◆ set_name()

virtual void Glom::TranslatableItem::set_name ( const Glib::ustring name)
virtualnoexcept

Set the non-translated identifier name.

Reimplemented in Glom::Field, and Glom::LayoutItem_Field.

◆ set_title()

void Glom::TranslatableItem::set_title ( const Glib::ustring title,
const Glib::ustring locale 
)
noexcept

Set the title's translation for the specified locale.

Parameters
titleThe text of the title.
localeThe locale whose title text should be set. If this is empty then the original text will be set.

◆ set_title_original()

void Glom::TranslatableItem::set_title_original ( const Glib::ustring title)
noexcept

Set the title's original (non-translated, usually English) text.

This is the same as calling set_title() with an empty locale parameter.

Member Data Documentation

◆ m_translatable_item_type

enumTranslatableItemType Glom::TranslatableItem::m_translatable_item_type
protected

The documentation for this class was generated from the following file: