Added the new i18n macro trVDR()

This commit is contained in:
Klaus Schmidinger 2007-08-24 14:03:47 +02:00
parent 98bdd0cfea
commit a241ad38b8
5 changed files with 29 additions and 26 deletions

View File

@ -2159,3 +2159,7 @@ Tobias Bratfisch <tobias@reel-multimedia.com>
Bruno Roussel <bruno.roussel@free.fr> Bruno Roussel <bruno.roussel@free.fr>
for translating OSD texts to the French language for translating OSD texts to the French language
Matthias Becker <becker.matthias@gmail.com>
for suggesting to add a new i18n macro that can be used by plugins to mark
texts they want to reuse from VDR's core translations

View File

@ -5396,3 +5396,6 @@ Video Disk Recorder Revision History
- Changed the default for LOCDIR in Makefile and Make.config.template to - Changed the default for LOCDIR in Makefile and Make.config.template to
"./locale", so that internationalization works by default when running VDR "./locale", so that internationalization works by default when running VDR
from within its source directory (suggested by Anssi Hannula). from within its source directory (suggested by Anssi Hannula).
- Added the new i18n macro trVDR(), which can be used by plugins to mark
texts they want to reuse from VDR's core translations (suggested by Matthias
Becker).

View File

@ -6,7 +6,7 @@
<center><h1>The VDR Plugin System</h1></center> <center><h1>The VDR Plugin System</h1></center>
<center><b>Version 1.5.3</b></center> <center><b>Version 1.5.8</b></center>
<p> <p>
<center> <center>
Copyright &copy; 2006 Klaus Schmidinger<br> Copyright &copy; 2006 Klaus Schmidinger<br>
@ -14,18 +14,18 @@ Copyright &copy; 2006 Klaus Schmidinger<br>
<a href="http://www.cadsoft.de/vdr">www.cadsoft.de/vdr</a> <a href="http://www.cadsoft.de/vdr">www.cadsoft.de/vdr</a>
</center> </center>
<p> <p>
<!--X1.5.0--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%> <!--X1.5.1--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.5.0 are marked like this.
<!--X1.5.0--></td></tr></table>
<!--X1.5.1--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.5.1 are marked like this. Important modifications introduced in version 1.5.1 are marked like this.
<!--X1.5.1--></td></tr></table> <!--X1.5.1--></td></tr></table>
<!--X1.5.3--><table width=100%><tr><td bgcolor=#AA0000>&nbsp;</td><td width=100%> <!--X1.5.3--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.5.3 are marked like this. Important modifications introduced in version 1.5.3 are marked like this.
<!--X1.5.3--></td></tr></table> <!--X1.5.3--></td></tr></table>
<!--X1.5.7--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%> <!--X1.5.7--><table width=100%><tr><td bgcolor=#AA0000>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.5.7 are marked like this. Important modifications introduced in version 1.5.7 are marked like this.
<!--X1.5.7--></td></tr></table> <!--X1.5.7--></td></tr></table>
<!--X1.5.8--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.5.8 are marked like this.
<!--X1.5.8--></td></tr></table>
<p> <p>
VDR provides an easy to use plugin interface that allows additional functionality VDR provides an easy to use plugin interface that allows additional functionality
to be added to the program by implementing a dynamically loadable library file. to be added to the program by implementing a dynamically loadable library file.
@ -64,7 +64,7 @@ structures and allows it to hook itself into specific areas to perform special a
<li><a href="#Housekeeping">Housekeeping</a> <li><a href="#Housekeeping">Housekeeping</a>
<li><a href="#Main thread hook">Main thread hook</a> <li><a href="#Main thread hook">Main thread hook</a>
<li><a href="#Activity">Activity</a> <li><a href="#Activity">Activity</a>
<!--X1.5.1--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%> <!--X1.5.1--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%>
<li><a href="#Wakeup">Wakeup</a> <li><a href="#Wakeup">Wakeup</a>
<!--X1.5.1--></td></tr></table> <!--X1.5.1--></td></tr></table>
<li><a href="#Setup parameters">Setup parameters</a> <li><a href="#Setup parameters">Setup parameters</a>
@ -88,9 +88,7 @@ structures and allows it to hook itself into specific areas to perform special a
<li><a href="#Devices">Devices</a> <li><a href="#Devices">Devices</a>
<li><a href="#Audio">Audio</a> <li><a href="#Audio">Audio</a>
<li><a href="#Remote Control">Remote Control</a> <li><a href="#Remote Control">Remote Control</a>
<!--X1.5.0--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%>
<li><a href="#Conditional Access">Conditional Access</a> <li><a href="#Conditional Access">Conditional Access</a>
<!--X1.5.0--></td></tr></table>
</ul> </ul>
</ul> </ul>
@ -687,7 +685,7 @@ be queried, and further prompts may show up. If all prompts have been confirmed,
the shutdown will take place. As soon as one prompt is not confirmed, no the shutdown will take place. As soon as one prompt is not confirmed, no
further plugins will be queried and no shutdown will be done. further plugins will be queried and no shutdown will be done.
<!--X1.5.1--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%> <!--X1.5.1--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%>
<a name="Wakeup"><hr><h2>Wakeup</h2> <a name="Wakeup"><hr><h2>Wakeup</h2>
<center><i><b>Wake me up before you go-go</b></i></center><p> <center><i><b>Wake me up before you go-go</b></i></center><p>
@ -912,7 +910,7 @@ const char *MyConfigDir = cPlugin::ConfigDirectory();
<center><i><b>Welcome to Babylon!</b></i></center><p> <center><i><b>Welcome to Babylon!</b></i></center><p>
<!--X1.5.7--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%> <!--X1.5.7--><table width=100%><tr><td bgcolor=#AA0000>&nbsp;</td><td width=100%>
If a plugin displays texts to the user, it should prepare for internationalization If a plugin displays texts to the user, it should prepare for internationalization
of these texts. All that is necessary for this is to mark every text that is of these texts. All that is necessary for this is to mark every text that is
presented to the user as translatable, as in presented to the user as translatable, as in
@ -923,9 +921,12 @@ const char *s = tr("Hello world!");
The text given here must be the English version, and the returned pointer is either The text given here must be the English version, and the returned pointer is either
a translated version (if available) or the original string. a translated version (if available) or the original string.
Texts are first searched for in the domain registered for this plugin (if any) <!--X1.5.8--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%>
and then in the global VDR texts. So a plugin can make use of texts defined by the Texts are searched for in the domain registered for this plugin.
core VDR code. If a plugin wants to make use of texts defined by the core VDR code, it can use
the special <tt>trVDR()</tt> macro to mark these texts without having them
appear in its own translation file.
<!--X1.5.8--></td></tr></table>
<p> <p>
Sometimes texts are stored in an array, in which case they need to be marked Sometimes texts are stored in an array, in which case they need to be marked
differently, using the trNOOP() macro. The actual translation is then done differently, using the trNOOP() macro. The actual translation is then done
@ -943,7 +944,7 @@ for (int i = 0; i &lt; 3; i++)
</pre></td></tr></table><p> </pre></td></tr></table><p>
<p> <p>
<!--X1.5.3--><table width=100%><tr><td bgcolor=#AA0000>&nbsp;</td><td width=100%> <!--X1.5.3--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%>
The system VDR is running on may use a character encoding where a single character The system VDR is running on may use a character encoding where a single character
(or <i>symbol</i>) consists of more than one byte (UTF-8, as opposed to, for instance, (or <i>symbol</i>) consists of more than one byte (UTF-8, as opposed to, for instance,
ISO8859-1, where every character is represented by a single byte in memory). ISO8859-1, where every character is represented by a single byte in memory).
@ -1605,7 +1606,7 @@ with the full required resolution. Only if this fails shall it use alternate
areas. Drawing areas are always rectangular and may not overlap (but do not need areas. Drawing areas are always rectangular and may not overlap (but do not need
to be adjacent). to be adjacent).
<p> <p>
<!--X1.5.3--><table width=100%><tr><td bgcolor=#AA0000>&nbsp;</td><td width=100%> <!--X1.5.3--><table width=100%><tr><td bgcolor=#00AA00>&nbsp;</td><td width=100%>
Special consideration may have to be given to color usage if the OSD provides Special consideration may have to be given to color usage if the OSD provides
8bpp (256 colors). In that case, fonts may be drawn using <i>anti-aliasing</i>, 8bpp (256 colors). In that case, fonts may be drawn using <i>anti-aliasing</i>,
which requires several blended color values between the foreground and background which requires several blended color values between the foreground and background
@ -2088,7 +2089,6 @@ Put(uint64 Code, bool Repeat = false, bool Release = false);
The other parameters have the same meaning as in the first version of this function. The other parameters have the same meaning as in the first version of this function.
<!--X1.5.0--><table width=100%><tr><td bgcolor=#0000AA>&nbsp;</td><td width=100%>
<a name="Conditional Access"><hr><h2>Conditional Access</h2> <a name="Conditional Access"><hr><h2>Conditional Access</h2>
<center><i><b>Members only!</b></i></center><p> <center><i><b>Members only!</b></i></center><p>
@ -2123,7 +2123,6 @@ virtual bool Assign(cDevice *Device, bool Query = false);
</pre></td></tr></table><p> </pre></td></tr></table><p>
See the description of this function in <tt>ci.h</tt> for details. See the description of this function in <tt>ci.h</tt> for details.
<!--X1.5.0--></td></tr></table>
</body> </body>
</html> </html>

8
i18n.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: i18n.c 1.316 2007/08/24 13:15:48 kls Exp $ * $Id: i18n.c 1.317 2007/08/24 14:03:47 kls Exp $
* *
* *
*/ */
@ -206,11 +206,7 @@ const char *I18nTranslate(const char *s, const char *Plugin)
if (!s) if (!s)
return s; return s;
if (CurrentLanguage) { if (CurrentLanguage) {
const char *t = s; const char *t = Plugin ? dgettext(Plugin, s) : gettext(s);
if (Plugin)
t = dgettext(Plugin, s);
if (t == s)
t = gettext(s);
if (t != s) if (t != s)
return t; return t;
} }

3
i18n.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: i18n.h 1.23 2007/08/19 14:07:17 kls Exp $ * $Id: i18n.h 1.24 2007/08/24 13:35:18 kls Exp $
*/ */
#ifndef __I18N_H #ifndef __I18N_H
@ -80,6 +80,7 @@ bool I18nIsPreferredLanguage(int *PreferredLanguages, const char *LanguageCode,
#ifdef PLUGIN_NAME_I18N #ifdef PLUGIN_NAME_I18N
#define tr(s) I18nTranslate(s, "vdr-" PLUGIN_NAME_I18N) #define tr(s) I18nTranslate(s, "vdr-" PLUGIN_NAME_I18N)
#define trVDR(s) I18nTranslate(s) // to use a text that's in the VDR core's translation file
#else #else
#define tr(s) I18nTranslate(s) #define tr(s) I18nTranslate(s)
#endif #endif