Added a class for deferred translation of strings.

This commit is contained in:
Moritz Bunkus 2009-08-07 15:18:32 +02:00
parent cc0276ed83
commit 2a4999959b
3 changed files with 45 additions and 1 deletions

View File

@ -339,7 +339,8 @@ maintainer-clean: distclean
update-po:
@echo 'XGETTEXT'
@xgettext --keyword=Y --keyword=Z --keyword=TIP --default-domain=mkvtoolnix --from-code=UTF-8 -s --omit-header -o po/mkvtoolnix.pot \
@xgettext --keyword=YT --keyword=Y --keyword=Z --keyword=TIP \
--default-domain=mkvtoolnix --from-code=UTF-8 -s --omit-header -o po/mkvtoolnix.pot \
$(ALL_SOURCES) $(ALL_HEADERS)
@for i in po/*.po ; do \
echo 'MSGMERGE ' $$i ; \

View File

@ -150,6 +150,34 @@ translation_c::get_locale() {
#endif
}
// ------------------------------------------------------------
translatable_string_c::translatable_string_c()
{
}
translatable_string_c::translatable_string_c(const std::string &untranslated_string)
: m_untranslated_string(untranslated_string)
{
}
translatable_string_c::translatable_string_c(const char *untranslated_string)
: m_untranslated_string(untranslated_string)
{
}
std::string
translatable_string_c::get_translated() {
return m_untranslated_string.empty() ? "" : Y(m_untranslated_string.c_str());
}
std::string
translatable_string_c::get_untranslated() {
return m_untranslated_string;
}
// ------------------------------------------------------------
#if defined(HAVE_LIBINTL_H)
void

View File

@ -39,6 +39,21 @@ public:
static std::string get_default_ui_locale();
};
class MTX_DLL_API translatable_string_c {
protected:
std::string m_untranslated_string;
public:
translatable_string_c();
translatable_string_c(const std::string &untranslated_string);
translatable_string_c(const char *untranslated_string);
std::string get_translated();
std::string get_untranslated();
};
#define YT(s) translatable_string_c(s)
void MTX_DLL_API init_locales(std::string locale = "");
#endif // __MTX_COMMON_TRANSLATION_H