This file is indexed.

/usr/share/gtk-doc/html/libtranslate/TranslateService.html is in libtranslate-dev 0.99-0ubuntu9.

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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>TranslateService</title><meta name="generator" content="DocBook XSL Stylesheets V1.66.1"><link rel="start" href="index.html" title="libtranslate Reference Manual"><link rel="up" href="api-reference.html" title="API Reference"><link rel="prev" href="TranslatePair.html" title="TranslatePair"><link rel="next" href="TranslateSession.html" title="TranslateSession"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><style type="text/css">
        .synopsis, .classsynopsis {
            background: #eeeeee;
            border: solid 1px #aaaaaa;
            padding: 0.5em;
        }
        .programlisting {
            background: #eeeeff;
            border: solid 1px #aaaaff;
            padding: 0.5em;
        }
        .variablelist {
            padding: 4px;
            margin-left: 3em;
        }
        .navigation {
            background: #ffeeee;
            border: solid 1px #ffaaaa;
            margin-top: 0.5em;
            margin-bottom: 0.5em;
        }
        .navigation a {
            color: #770000;
        }
        .navigation a:visited {
            color: #550000;
        }
        .navigation .title {
            font-size: 200%;
        }
      </style></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="TranslatePair.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="api-reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">libtranslate Reference Manual</th><td><a accesskey="n" href="TranslateSession.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="TranslateService"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">TranslateService</span></h2><p>TranslateService &#8212; service object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">



struct      <a href="TranslateService.html#TranslateService-struct">TranslateService</a>;
struct      <a href="TranslateService.html#TranslateServiceClass">TranslateServiceClass</a>;
const char* <a href="TranslateService.html#translate-service-get-name">translate_service_get_name</a>      (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);
const char* <a href="TranslateService.html#translate-service-get-nick">translate_service_get_nick</a>      (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);
unsigned int <a href="TranslateService.html#translate-service-get-max-chunk-len">translate_service_get_max_chunk_len</a>
                                            (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);
const GSList* <a href="TranslateService.html#translate-service-get-pairs">translate_service_get_pairs</a>   (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);

</pre></div><div class="refsect1" lang="en"><a name="id2605074"></a><h2>Object Hierarchy</h2><pre class="synopsis">

  GObject
   +----TranslateService
</pre></div><div class="refsect1" lang="en"><a name="id2605091"></a><h2>Properties</h2><pre class="synopsis">

  "<a href="TranslateService.html#TranslateService--max-chunk-len">max-chunk-len</a>"        guint                : Read / Write / Construct Only
  "<a href="TranslateService.html#TranslateService--name">name</a>"                 gchararray           : Read / Write / Construct Only
  "<a href="TranslateService.html#TranslateService--nick">nick</a>"                 gchararray           : Read / Write / Construct Only
  "<a href="TranslateService.html#TranslateService--pairs">pairs</a>"                gpointer             : Read
</pre></div><div class="refsect1" lang="en"><a name="id2605217"></a><h2>Description</h2><p>
A <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> object defines a set of language pairs as well as
the methods to translate a text or web page using one of the pairs.
</p><p>
A new translation service can be implemented in two ways:
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term">Adding a definition to the <tt class="filename">services.xml</tt> file</span></td><td><p>
The generic module provides an abstract framework for supporting
web-based translation services. At runtime, the generic module reads
service definitions from <tt class="filename">services.xml</tt> files and
creates the services defined in these files.
</p><p>
If you are adding support for a web-based translation service, this is
the way to go. See the
<span class="citerefentry"><span class="refentrytitle">services.xml</span>(5)</span>
manual page for more details.
</p></td></tr><tr><td><span class="term">Creating a <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> subclass</span></td><td><p>
If the <tt class="filename">services.xml</tt> file cannot satisfactorily be
used to describe the service you want to implement, you need to
program the service in C by creating a subclass of <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a>
and overriding the <i class="parameter"><tt>get_pairs</tt></i>, <i class="parameter"><tt>translate_text</tt></i> and/or
<i class="parameter"><tt>translate_web_page</tt></i> methods.
</p><p>
If you want all the applications using libtranslate to be able to use
the new service, you need to create a libtranslate module and install
it in the appropriate path (see <a href="compiling-modules.html" title="Compiling libtranslate Modules">Compiling libtranslate Modules</a>).
Otherwise, just integrate the service with your application. In either
case, you need to expose an instance of the service to libtranslate by
calling <a href="libtranslate-translate.html#translate-add-service"><tt class="function">translate_add_service()</tt></a>. If the service is included in a module,
this needs to be done from <tt class="function">translate_module_init()</tt>. Otherwise, do it
from your application initialization code, somewhere after the call to
<a href="libtranslate-translate.html#translate-init"><tt class="function">translate_init()</tt></a>.
</p></td></tr></tbody></table></div></div><div class="refsect1" lang="en"><a name="id2605424"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2605429"></a><h3><a name="TranslateService-struct"></a>struct TranslateService</h3><a class="indexterm" name="id2605437"></a><pre class="programlisting">struct TranslateService;</pre><p>
The <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> struct contains private data only, and should be
accessed using the functions below.
</p></div><hr><div class="refsect2" lang="en"><a name="id2605458"></a><h3><a name="TranslateServiceClass"></a>struct TranslateServiceClass</h3><a class="indexterm" name="id2605466"></a><pre class="programlisting">struct TranslateServiceClass {

  GObjectClass		parent;


  gboolean	 (*get_pairs)		(TranslateService	 *service,
					 GSList			**pairs,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err);
  char		*(*translate_text)	(TranslateService	 *service,
					 const char		 *text,
					 const char		 *from,
					 const char		 *to,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err);
  char		*(*translate_web_page)	(TranslateService	 *service,
					 const char		 *url,
					 const char		 *from,
					 const char		 *to,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err);

};
</pre><p>
The service class contains methods which should be implemented by
subclasses in order to provide the service functionality.
</p><p>
Implementing the <i class="parameter"><tt>get_pairs</tt></i> method is mandatory. The <i class="parameter"><tt>translate_text</tt></i>
and <i class="parameter"><tt>translate_web_page</tt></i> methods are only required if any pair returned
by the <i class="parameter"><tt>get_pairs</tt></i> method has the <span class="type">TRANSLATE_PAIR_TEXT</span> or
<span class="type">TRANSLATE_PAIR_WEB_PAGE</span> flag set, respectively.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term">GObjectClass <i class="structfield"><tt>parent</tt></i></span></td><td>the parent class
</td></tr><tr><td><span class="term">gboolean (*<i class="structfield"><tt>get_pairs</tt></i>) (TranslateService	 *service,
					 GSList			**pairs,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err)</span></td><td>Specifies the function which is called to retrieve the
list of language pairs implemented by <i class="parameter"><tt>service</tt></i>. The function should
return <tt class="literal">TRUE</tt> and store a list of <a href="TranslatePair.html" title="TranslatePair"><span class="type">TranslatePair</span></a> objects in <i class="parameter"><tt>pairs</tt></i> on
success, or return <tt class="literal">FALSE</tt> and store an error in <i class="parameter"><tt>err</tt></i> on failure. If
<i class="parameter"><tt>progress_func</tt></i> is not <tt class="literal">NULL</tt>, <i class="parameter"><tt>get_pairs</tt></i> should call it at regular
intervals with a progress update (or -1 if the progress is unknown),
and the <i class="parameter"><tt>user_data</tt></i> argument. If, when called, <i class="parameter"><tt>progress_func</tt></i> returns
<tt class="literal">FALSE</tt>, <i class="parameter"><tt>get_pairs</tt></i> must cancel the operation as soon as possible,
return <tt class="literal">NULL</tt>, and set <i class="parameter"><tt>err</tt></i> to an error of domain <a href="libtranslate-translate.html#TRANSLATE-ERROR-CAPS"><span class="type">TRANSLATE_ERROR</span></a> and
code <span class="type">TRANSLATE_ERROR_CANCELLED</span>.
</td></tr><tr><td><span class="term">char* (*<i class="structfield"><tt>translate_text</tt></i>) (TranslateService	 *service,
					 const char		 *text,
					 const char		 *from,
					 const char		 *to,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err)</span></td><td>Specifies the function which is called to translate a
chunk of text. The function should return a newly-allocated string
containing the translation of <i class="parameter"><tt>text</tt></i> on success, or return <tt class="literal">NULL</tt> and
set <i class="parameter"><tt>err</tt></i> on failure. If the <a href="TranslateService.html#TranslateService--max-chunk-len">max-chunk-len</a>
property of service is not 0, it is guaranteed that the number of
UTF-8 characters in <i class="parameter"><tt>text</tt></i> will not exceed <a href="TranslateService.html#TranslateService--max-chunk-len">max-chunk-len</a> . It is
guaranteed that the <i class="parameter"><tt>from</tt></i>/<i class="parameter"><tt>to</tt></i> pair will be a member (with the flag
<span class="type">TRANSLATE_PAIR_TEXT</span> set) of the list returned by the <i class="parameter"><tt>get_pairs</tt></i>
method. If <i class="parameter"><tt>progress_func</tt></i> is not <tt class="literal">NULL</tt>, <i class="parameter"><tt>translate_text</tt></i> should call it
at regular intervals with a progress update (or -1 if the progress is
unknown), and the <i class="parameter"><tt>user_data</tt></i> argument. If, when called, <i class="parameter"><tt>progress_func</tt></i>
returns <tt class="literal">FALSE</tt>, <i class="parameter"><tt>translate_text</tt></i> must cancel the translation as soon as
possible, return <tt class="literal">NULL</tt>, and set <i class="parameter"><tt>err</tt></i> to an error of domain
<a href="libtranslate-translate.html#TRANSLATE-ERROR-CAPS"><span class="type">TRANSLATE_ERROR</span></a> and code <span class="type">TRANSLATE_ERROR_CANCELLED</span>.
</td></tr><tr><td><span class="term">char* (*<i class="structfield"><tt>translate_web_page</tt></i>) (TranslateService	 *service,
					 const char		 *url,
					 const char		 *from,
					 const char		 *to,
					 TranslateProgressFunc	  progress_func,
					 gpointer		  user_data,
					 GError			**err)</span></td><td>Specifies the function which is called to
translate a web page. The function should return a newly-allocated
string containing the URL of the translated web page on success, or
return <tt class="literal">NULL</tt> and set <i class="parameter"><tt>err</tt></i> on failure. It is guaranteed that the
<i class="parameter"><tt>from</tt></i>/<i class="parameter"><tt>to</tt></i> pair will be a member (with the flag
<span class="type">TRANSLATE_PAIR_WEB_PAGE</span> set) of the list returned by the <i class="parameter"><tt>get_pairs</tt></i>
method. If <i class="parameter"><tt>progress_func</tt></i> is not <tt class="literal">NULL</tt>, <i class="parameter"><tt>translate_web_page</tt></i> should
call it at regular intervals with a progress update (or -1 if the
progress is unknown), and the <i class="parameter"><tt>user_data</tt></i> argument. If, when called,
<i class="parameter"><tt>progress_func</tt></i> returns <tt class="literal">FALSE</tt>, <i class="parameter"><tt>translate_web_page</tt></i> must cancel the
translation as soon as possible, return <tt class="literal">NULL</tt>, and set <i class="parameter"><tt>err</tt></i> to an
error of domain <a href="libtranslate-translate.html#TRANSLATE-ERROR-CAPS"><span class="type">TRANSLATE_ERROR</span></a> and code <span class="type">TRANSLATE_ERROR_CANCELLED</span>.

</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2606042"></a><h3><a name="translate-service-get-name"></a>translate_service_get_name ()</h3><a class="indexterm" name="id2606051"></a><pre class="programlisting">const char* translate_service_get_name      (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);</pre><p>
Gets the symbolic name of <i class="parameter"><tt>service</tt></i>.</p><p>

</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>service</tt></i> :</span></td><td> a service.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the symbolic name of <i class="parameter"><tt>service</tt></i>, encoded in ASCII.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2606117"></a><h3><a name="translate-service-get-nick"></a>translate_service_get_nick ()</h3><a class="indexterm" name="id2606125"></a><pre class="programlisting">const char* translate_service_get_nick      (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);</pre><p>
Gets the human-readable name of <i class="parameter"><tt>service</tt></i>.</p><p>

</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>service</tt></i> :</span></td><td> a service.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the human-readable name of <i class="parameter"><tt>service</tt></i>.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2606193"></a><h3><a name="translate-service-get-max-chunk-len"></a>translate_service_get_max_chunk_len ()</h3><a class="indexterm" name="id2606205"></a><pre class="programlisting">unsigned int translate_service_get_max_chunk_len
                                            (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);</pre><p>
Gets the maximum chunk length of <i class="parameter"><tt>service</tt></i>.</p><p>

</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>service</tt></i> :</span></td><td> a service.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the maximum chunk length of <i class="parameter"><tt>service</tt></i>, in characters.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2606273"></a><h3><a name="translate-service-get-pairs"></a>translate_service_get_pairs ()</h3><a class="indexterm" name="id2606281"></a><pre class="programlisting">const GSList* translate_service_get_pairs   (<a href="TranslateService.html" title="TranslateService">TranslateService</a> *service);</pre><p>
Gets the list of language pairs implemented by <i class="parameter"><tt>service</tt></i>.</p><p>

</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>service</tt></i> :</span></td><td> a service.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a list of <a href="TranslatePair.html" title="TranslatePair"><span class="type">TranslatePair</span></a> objects.
</td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id2606350"></a><h2>Properties</h2><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a name="TranslateService--max-chunk-len"></a>"<tt class="literal">max-chunk-len</tt>" (guint : Read / Write / Construct Only)</span></td><td><p>The maximum length of an input chunk, in characters (0 means unlimited).</p></td></tr><tr><td><span class="term"><a name="TranslateService--name"></a>"<tt class="literal">name</tt>" (gchararray : Read / Write / Construct Only)</span></td><td><p>The service symbolic name, encoded in ASCII.</p></td></tr><tr><td><span class="term"><a name="TranslateService--nick"></a>"<tt class="literal">nick</tt>" (gchararray : Read / Write / Construct Only)</span></td><td><p>The service human-readable name.</p></td></tr><tr><td><span class="term"><a name="TranslateService--pairs"></a>"<tt class="literal">pairs</tt>" (gpointer : Read)</span></td><td><p>The list of language pairs this service implements.</p></td></tr></tbody></table></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="TranslatePair.html"><b>&lt;&lt; TranslatePair</b></a></td><td align="right"><a accesskey="n" href="TranslateSession.html"><b>TranslateSession &gt;&gt;</b></a></td></tr></table></body></html>