/usr/share/gtk-doc/html/libaccounts-glib/gettext-xml-files.html is in libaccounts-glib-doc 1.15+14.04.20131126.2-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>libaccounts-glib Reference Manual: Internationalizing XML data files using gettext</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="libaccounts-glib Reference Manual">
<link rel="up" href="xml-file-formats.html" title="XML files">
<link rel="prev" href="service-type-file-format.html" title="Service type description file format">
<link rel="next" href="validating-xml-files.html" title="Validating XML files against the DTDs">
<meta name="generator" content="GTK-Doc V1.20 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="10"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="xml-file-formats.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="service-type-file-format.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="validating-xml-files.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="gettext-xml-files"></a>Internationalizing XML data files using gettext</h2></div></div></div>
<p>
Strings to be shown to the user which are found in the <acronym title="
The eXtensible Markup Language defines a set of rules for marking up
documents that are both machine- and human-readable.
"><span class="acronym">XML</span></acronym>
data files supported by libaccounts-glib can be localized to the user's
language. For this purpose, a
<code class="sgmltag-element">translations</code> element is present
to identify the gettext translation domain, which can then be used by
applications which consume those strings in order to request gettext to
localize the text. Thus, the burden of localization is split between the author
of the data file and the application developer. The following sections will
give brief explanations of how to simplify both tasks.
</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="intltool-xml-files"></a>
Using <span class="application">intltool</span> to extract translatable strings
</h3></div></div></div>
<p>
<span class="command"><strong>intltool</strong></span> is a helper tool to make internationalization
easier for application developers. Using intltool, a developer can extract
the translatable strings from XML data files with ease. There are several
steps that must be taken to integrate intltool to extract translatable
strings, as described below.
</p>
<div class="procedure"><ol class="procedure" type="1">
<li class="step">
<p>
Ensure that each XML data file has a
<code class="sgmltag-element">translations</code> element, containing the
gettext tranlslation domain for the application. This will generally be the
name of the package, and is often set in <code class="filename">configure.ac</code>
with:
</p>
<div class="informalexample"><pre class="programlisting">AC_SUBST([GETTEXT_PACKAGE], [$PACKAGE_TARNAME])</pre></div>
</li>
<li class="step"><p>
Add a <code class="filename">.in</code> to the end of the name of
the XML data file. For example, rename
<code class="filename"><em class="replaceable"><code>my-application</code></em>.application</code>
to
<code class="filename"><em class="replaceable"><code>my-application</code></em>.application.in</code>.
</p></li>
<li class="step"><p>
Translatable elements in an XML file must be marked for translation by
adding an underscore at the beginning of the element name. For example,
<code class="literal"><description></code> would change to
<code class="literal"><_description></code>. An underscore prefix must also be
added to the corresponding closing element.
</p></li>
<li class="step">
<p>
The strings that are marked for translation must be extracted by intltool.
This simply creates a corresponding XML data file, without the
<code class="filename">.in</code> extension, and places the
marked strings in the intltool cache. The following
<span class="application">automake</span> snippet will extract the marked strings
and distribute and install the resulting provider file:
</p>
<div class="informalexample"><pre class="programlisting"># Extract transatable strings from .provider file
my-provider.provider: my-provider.provider.in $(INTLTOOL_MERGE)
$(INTLTOOL_V_MERGE) LC_ALL=C $(INTLTOOL_MERGE) $(INTLTOOL_MERGE_V_OPTIONS) --no-translations -x -u $< $@
provider_in_file = \
my-provider.provider.in
providerdir = $(datadir)/accounts/providers
provider_DATA = \
$(providers_in_file:.provider.in=.provider)
dist_noinst_DATA = \
$(provider_in_file)
CLEANFILES = \
$(provider_DATA)</pre></div>
</li>
<li class="step">
<p>
Add the <code class="filename">.in</code> to
<code class="filename">po/POTFILES.in</code>, being sure to list the file type
alongside it. For example, with a service file
<code class="filename"><em class="replaceable"><code>my-service</code></em>.service.in</code> in
the <code class="filename">data</code> directory in the source
tree, the <code class="filename">POTFILES.in</code> addition would be:
</p>
<div class="informalexample"><pre class="programlisting">[type: gettext/xml]data/my-service.service.in</pre></div>
</li>
</ol></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="gettext-xml-files-applications"></a>
Using <span class="application">gettext</span> to localize translatable strings
</h3></div></div></div>
<p>
<span class="application">gettext</span> is used to show the localized versions of
translatable strings that have been extracted and translated. As most use of
gettext in a client application involves translatable strings only from that
application, it is common practice to bind the translataion domain of the
application as the default, which is normally done as follows:
</p>
<div class="informalexample"><pre class="programlisting">bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);</pre></div>
<p>
If the translation domain is bound in this way, then when requesting
translation of text from another project, such as the XML data files used by
libaccounts-glib, the domain must be specified explicitly. The
<code class="function">dgettext</code> function can be used for this purpose. As an
example, for a hypothetical service <code class="varname">foo_service</code> calling
dgettext could be done as follows:
</p>
<div class="informalexample"><pre class="programlisting">dgettext (ag_service_get_i18n_domain (foo_service),
ag_service_get_description (foo_service));</pre></div>
<p>
This returns the translated string, which can then be shown to the user.
</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.20</div>
</body>
</html>
|