Added support for the gettext context feature
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9862 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
cd8162c30f
commit
5e905e4322
@ -26,10 +26,7 @@ echo "---------------------------"
|
||||
echo " Generating .pot file..."
|
||||
|
||||
# C++ Files
|
||||
xgettext -d supertuxkart -s --keyword=_ --keyword=N_ --keyword=_LTR --add-comments="I18N:" -p ./data/po -o supertuxkart.pot $CPP_FILE_LIST --package-name=supertuxkart
|
||||
|
||||
# Lisp files
|
||||
#xgettext -j -L lisp -d supertuxkart -s --keyword=_ --add-comments="I18N:" -p ./data/po -o supertuxkart.pot $XML_FILE_LIST --package-name=supertuxkart
|
||||
xgettext -d supertuxkart -s --keyword=_ --keyword=N_ --keyword=_LTR --keyword=_C:1c,2 --add-comments="I18N:" -p ./data/po -o supertuxkart.pot $CPP_FILE_LIST --package-name=supertuxkart
|
||||
|
||||
# XML Files
|
||||
xgettext -j -d supertuxkart -s --keyword=_ --add-comments="I18N:" -p ./data/po -o supertuxkart.pot --from-code=UTF-8 ./data/po/gui_strings.h --package-name=supertuxkart
|
||||
|
@ -317,7 +317,7 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
|
||||
irr::core::stringw m_fastest_lap_message;
|
||||
//I18N: as in "fastest lap: 60 seconds by Wilber"
|
||||
m_fastest_lap_message += _("%s by %s", s.c_str(),
|
||||
m_fastest_lap_message += _C("fastest_lap", "%s by %s", s.c_str(),
|
||||
core::stringw(kart->getName()));
|
||||
|
||||
m_race_gui->addMessage(m_fastest_lap_message, NULL,
|
||||
|
@ -187,7 +187,7 @@ void AddonsScreen::loadList()
|
||||
else
|
||||
{
|
||||
//I18N: as in: The Old Island by Johannes Sjolund
|
||||
s = _("%s by %s",addon->getName().c_str(),addon->getDesigner().c_str());
|
||||
s = _C("addons", "%s by %s", addon->getName().c_str(),addon->getDesigner().c_str());
|
||||
}
|
||||
|
||||
// check if text is too long to fit
|
||||
|
@ -345,12 +345,22 @@ const wchar_t* Translations::fribidize(const wchar_t* in_ptr)
|
||||
return in_ptr;
|
||||
}
|
||||
|
||||
const wchar_t* Translations::w_gettext(const wchar_t* original)
|
||||
/**
|
||||
* \param original Message to translate
|
||||
* \param context Optional, can be set to differentiate 2 strings that are identical
|
||||
* in English but could be different in other languages
|
||||
*/
|
||||
const wchar_t* Translations::w_gettext(const wchar_t* original, const char* context)
|
||||
{
|
||||
return w_gettext( wide_to_utf8(original) );
|
||||
return w_gettext( wide_to_utf8(original), context );
|
||||
}
|
||||
|
||||
const wchar_t* Translations::w_gettext(const char* original)
|
||||
/**
|
||||
* \param original Message to translate
|
||||
* \param context Optional, can be set to differentiate 2 strings that are identical
|
||||
* in English but could be different in other languages
|
||||
*/
|
||||
const wchar_t* Translations::w_gettext(const char* original, const char* context)
|
||||
{
|
||||
if (original[0] == '\0') return L"";
|
||||
|
||||
@ -358,7 +368,9 @@ const wchar_t* Translations::w_gettext(const char* original)
|
||||
std::cout << "Translating " << original << "\n";
|
||||
#endif
|
||||
|
||||
const std::string& original_t = m_dictionary.translate(original);
|
||||
const std::string& original_t = (context == NULL ?
|
||||
m_dictionary.translate(original) :
|
||||
m_dictionary.translate_ctxt(context, original));
|
||||
|
||||
if (original_t == original)
|
||||
{
|
||||
@ -385,6 +397,8 @@ const wchar_t* Translations::w_gettext(const char* original)
|
||||
return out_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Translations::isRTLLanguage() const
|
||||
{
|
||||
return m_rtl;
|
||||
|
@ -27,8 +27,9 @@
|
||||
|
||||
# include "tinygettext/tinygettext.hpp"
|
||||
|
||||
# define _(String, ...) (translations->fribidize(StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__)))
|
||||
# define _LTR(String, ...) (StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__))
|
||||
# define _(String, ...) (translations->fribidize(StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__)))
|
||||
# define _C(Ctx, String, ...) (translations->fribidize(StringUtils::insertValues(translations->w_gettext(String, Ctx), ##__VA_ARGS__)))
|
||||
# define _LTR(String, ...) (StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__))
|
||||
# define gettext_noop(String) (String)
|
||||
# define N_(String) (gettext_noop (String))
|
||||
// libintl defines its own fprintf, which doesn't work properly
|
||||
@ -48,8 +49,8 @@ private:
|
||||
public:
|
||||
Translations();
|
||||
|
||||
const wchar_t *w_gettext(const wchar_t* original);
|
||||
const wchar_t *w_gettext(const char* original);
|
||||
const wchar_t *w_gettext(const wchar_t* original, const char* context=NULL);
|
||||
const wchar_t *w_gettext(const char* original, const char* context=NULL);
|
||||
|
||||
bool isRTLLanguage() const;
|
||||
const wchar_t* fribidize(const wchar_t* in_ptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user