/usr/share/gtk-doc/html/libtranslate/TranslateSession.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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>TranslateSession</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="TranslateService.html" title="TranslateService"><link rel="next" href="libtranslate-translate-util.html" title="translate-util"><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="TranslateService.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="libtranslate-translate-util.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="TranslateSession"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">TranslateSession</span></h2><p>TranslateSession — session object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
struct <a href="TranslateSession.html#TranslateSession-struct">TranslateSession</a>;
#define <a href="TranslateSession.html#TRANSLATE-SESSION-ERROR-CAPS">TRANSLATE_SESSION_ERROR</a>
enum <a href="TranslateSession.html#TranslateSessionError">TranslateSessionError</a>;
<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a>* <a href="TranslateSession.html#translate-session-new">translate_session_new</a> (const GSList *services);
void <a href="TranslateSession.html#translate-session-set-services">translate_session_set_services</a> (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const GSList *services);
void <a href="TranslateSession.html#translate-session-set-max-threads">translate_session_set_max_threads</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
unsigned int max_threads);
void <a href="TranslateSession.html#translate-session-set-max-retries">translate_session_set_max_retries</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
unsigned int max_retries);
GSList* <a href="TranslateSession.html#translate-session-get-services">translate_session_get_services</a> (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);
GSList* <a href="TranslateSession.html#translate-session-get-pairs">translate_session_get_pairs</a> (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);
unsigned int <a href="TranslateSession.html#translate-session-get-max-threads">translate_session_get_max_threads</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);
int <a href="TranslateSession.html#translate-session-get-max-retries">translate_session_get_max_retries</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);
char* <a href="TranslateSession.html#translate-session-translate-text">translate_session_translate_text</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const char *text,
const char *from,
const char *to,
<a href="libtranslate-translate-common.html#TranslateProgressFunc">TranslateProgressFunc</a> progress_func,
gpointer user_data,
GError **err);
char* <a href="TranslateSession.html#translate-session-translate-web-page">translate_session_translate_web_page</a>
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const char *url,
const char *from,
const char *to,
<a href="libtranslate-translate-common.html#TranslateProgressFunc">TranslateProgressFunc</a> progress_func,
gpointer user_data,
GError **err);
</pre></div><div class="refsect1" lang="en"><a name="id2608510"></a><h2>Object Hierarchy</h2><pre class="synopsis">
GObject
+----TranslateSession
</pre></div><div class="refsect1" lang="en"><a name="id2608528"></a><h2>Properties</h2><pre class="synopsis">
"<a href="TranslateSession.html#TranslateSession--max-retries">max-retries</a>" gint : Read / Write / Construct
"<a href="TranslateSession.html#TranslateSession--max-threads">max-threads</a>" guint : Read / Write / Construct
"<a href="TranslateSession.html#TranslateSession--pairs">pairs</a>" gpointer : Read
"<a href="TranslateSession.html#TranslateSession--services">services</a>" gpointer : Read / Write / Construct
</pre></div><div class="refsect1" lang="en"><a name="id2608653"></a><h2>Description</h2><p>
A <a href="TranslateSession.html" title="TranslateSession"><span class="type">TranslateSession</span></a> object is used to translate a text or web page
using a set of translation services. After creating a new session with
<a href="TranslateSession.html#translate-session-new"><tt class="function">translate_session_new()</tt></a>, you can translate a text or web page using
<a href="TranslateSession.html#translate-session-translate-text"><tt class="function">translate_session_translate_text()</tt></a> or
<a href="TranslateSession.html#translate-session-translate-web-page"><tt class="function">translate_session_translate_web_page()</tt></a>.
</p></div><div class="refsect1" lang="en"><a name="id2608702"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2608708"></a><h3><a name="TranslateSession-struct"></a>struct TranslateSession</h3><a class="indexterm" name="id2608716"></a><pre class="programlisting">struct TranslateSession;</pre><p>
The <a href="TranslateSession.html" title="TranslateSession"><span class="type">TranslateSession</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="id2608737"></a><h3><a name="TRANSLATE-SESSION-ERROR-CAPS"></a>TRANSLATE_SESSION_ERROR</h3><a class="indexterm" name="id2608745"></a><pre class="programlisting">#define TRANSLATE_SESSION_ERROR (translate_session_error_quark())
</pre><p>
The error domain of <a href="TranslateSession.html#translate-session-translate-text"><tt class="function">translate_session_translate_text()</tt></a> and
<a href="TranslateSession.html#translate-session-translate-web-page"><tt class="function">translate_session_translate_web_page()</tt></a>. Errors in this domain are from
the <a href="TranslateSession.html#TranslateSessionError"><span class="type">TranslateSessionError</span></a> enumeration.
</p></div><hr><div class="refsect2" lang="en"><a name="id2608790"></a><h3><a name="TranslateSessionError"></a>enum TranslateSessionError</h3><a class="indexterm" name="id2608798"></a><pre class="programlisting">typedef enum
{
TRANSLATE_SESSION_ERROR_NO_SERVICE
} TranslateSessionError;
</pre><p>
Error codes returned by <a href="TranslateSession.html#translate-session-translate-text"><tt class="function">translate_session_translate_text()</tt></a> and
<a href="TranslateSession.html#translate-session-translate-web-page"><tt class="function">translate_session_translate_web_page()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><tt class="literal">TRANSLATE_SESSION_ERROR_NO_SERVICE</tt></span></td><td>no service could translate using
the given language pair
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2608856"></a><h3><a name="translate-session-new"></a>translate_session_new ()</h3><a class="indexterm" name="id2608865"></a><pre class="programlisting"><a href="TranslateSession.html" title="TranslateSession">TranslateSession</a>* translate_session_new (const GSList *services);</pre><p>
Creates a new translation session, which will use <i class="parameter"><tt>services</tt></i> for
performing translations.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>services</tt></i> :</span></td><td> a list of <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> objects to use. See
<a href="TranslateSession.html#translate-session-set-services"><tt class="function">translate_session_set_services()</tt></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a new translation session.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2608941"></a><h3><a name="translate-session-set-services"></a>translate_session_set_services ()</h3><a class="indexterm" name="id2608951"></a><pre class="programlisting">void translate_session_set_services (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const GSList *services);</pre><p>
Sets the services used by <i class="parameter"><tt>session</tt></i>. Default value: <tt class="literal">NULL</tt>.
</p><p>
The list of services determines the available language pairs (see
<a href="TranslateSession.html#translate-session-get-pairs"><tt class="function">translate_session_get_pairs()</tt></a>). The order of the list is important,
as <a href="TranslateSession.html#translate-session-translate-text"><tt class="function">translate_session_translate_text()</tt></a> and
<a href="TranslateSession.html#translate-session-translate-web-page"><tt class="function">translate_session_translate_web_page()</tt></a> iterate over the list until
the translation can be performed.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>services</tt></i> :</span></td><td> a list of <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> objects to use.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609069"></a><h3><a name="translate-session-set-max-threads"></a>translate_session_set_max_threads ()</h3><a class="indexterm" name="id2609082"></a><pre class="programlisting">void translate_session_set_max_threads
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
unsigned int max_threads);</pre><p>
Sets the maximum number of concurrent threads to use for
translating text. Default value: 8.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>max_threads</tt></i> :</span></td><td> a maximum number of threads.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609213"></a><h3><a name="translate-session-set-max-retries"></a>translate_session_set_max_retries ()</h3><a class="indexterm" name="id2609226"></a><pre class="programlisting">void translate_session_set_max_retries
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
unsigned int max_retries);</pre><p>
Sets the maximum number of retries per text chunk. Default value:
3.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>max_retries</tt></i> :</span></td><td> a maximum number of retries.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609289"></a><h3><a name="translate-session-get-services"></a>translate_session_get_services ()</h3><a class="indexterm" name="id2609299"></a><pre class="programlisting">GSList* translate_session_get_services (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);</pre><p>
Gets the services used by session. When no longer needed, the list
should be freed with:
</p><p>
</p><pre class="programlisting">
g_slist_foreach(list, (GFunc) g_object_unref, NULL);
g_slist_free(list);
</pre><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the list of <a href="TranslateService.html" title="TranslateService"><span class="type">TranslateService</span></a> objects used by
<i class="parameter"><tt>session</tt></i>.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609372"></a><h3><a name="translate-session-get-pairs"></a>translate_session_get_pairs ()</h3><a class="indexterm" name="id2609381"></a><pre class="programlisting">GSList* translate_session_get_pairs (<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);</pre><p>
Gets the list of language pairs available for translations. When no longer
needed, the list should be freed with:
</p><p>
</p><pre class="programlisting">
g_slist_foreach(list, (GFunc) g_object_unref, NULL);
g_slist_free(list);
</pre><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the list of <a href="TranslatePair.html" title="TranslatePair"><span class="type">TranslatePair</span></a> objects available for
translations.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609518"></a><h3><a name="translate-session-get-max-threads"></a>translate_session_get_max_threads ()</h3><a class="indexterm" name="id2609531"></a><pre class="programlisting">unsigned int translate_session_get_max_threads
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);</pre><p>
Gets the maximum number of concurrent threads to use for
translating text.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the maximum number of threads.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609588"></a><h3><a name="translate-session-get-max-retries"></a>translate_session_get_max_retries ()</h3><a class="indexterm" name="id2609601"></a><pre class="programlisting">int translate_session_get_max_retries
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session);</pre><p>
Gets the maximum number of retries per text chunk.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the maximum number of retries.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609657"></a><h3><a name="translate-session-translate-text"></a>translate_session_translate_text ()</h3><a class="indexterm" name="id2609670"></a><pre class="programlisting">char* translate_session_translate_text
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const char *text,
const char *from,
const char *to,
<a href="libtranslate-translate-common.html#TranslateProgressFunc">TranslateProgressFunc</a> progress_func,
gpointer user_data,
GError **err);</pre><p>
Translates text from the language <i class="parameter"><tt>from</tt></i> into the language <i class="parameter"><tt>to</tt></i>.
</p><p>
If <i class="parameter"><tt>progress_func</tt></i> is specified, it <span class="emphasis"><em>may</em></span> be
called periodically to report progress. If, when called,
<i class="parameter"><tt>progress_func</tt></i> returns <tt class="literal">FALSE</tt>, the translation is cancelled as soon
as possible, <tt class="literal">NULL</tt> is returned, and <i class="parameter"><tt>err</tt></i> is set 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>.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>text</tt></i> :</span></td><td> a nul-terminated string.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>from</tt></i> :</span></td><td> a RFC 3066 language tag.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>to</tt></i> :</span></td><td> a RFC 3066 language tag.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>progress_func</tt></i> :</span></td><td> a function to call when progressing, or <tt class="literal">NULL</tt>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td> data to pass to <i class="parameter"><tt>progress_func</tt></i>, or <tt class="literal">NULL</tt>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>err</tt></i> :</span></td><td> a location to report errors, or <tt class="literal">NULL</tt>. Any of the errors in
<a href="TranslateSession.html#TranslateSessionError"><span class="type">TranslateSessionError</span></a>, <a href="libtranslate-translate.html#TranslateError"><span class="type">TranslateError</span></a> or other domains may occur.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the translated text on success, or <tt class="literal">NULL</tt> on failure
(in such case <i class="parameter"><tt>err</tt></i> is set). The returned string should be freed
when no longer needed.
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2609947"></a><h3><a name="translate-session-translate-web-page"></a>translate_session_translate_web_page ()</h3><a class="indexterm" name="id2609960"></a><pre class="programlisting">char* translate_session_translate_web_page
(<a href="TranslateSession.html" title="TranslateSession">TranslateSession</a> *session,
const char *url,
const char *from,
const char *to,
<a href="libtranslate-translate-common.html#TranslateProgressFunc">TranslateProgressFunc</a> progress_func,
gpointer user_data,
GError **err);</pre><p>
Translates a web page from the language <i class="parameter"><tt>from</tt></i> into the language
<i class="parameter"><tt>to</tt></i>.
</p><p>
If <i class="parameter"><tt>progress_func</tt></i> is specified, it <span class="emphasis"><em>may</em></span> be
called periodically to report progress. If, when called,
<i class="parameter"><tt>progress_func</tt></i> returns <tt class="literal">FALSE</tt>, the translation is cancelled as soon
as possible, <tt class="literal">NULL</tt> is returned, and <i class="parameter"><tt>err</tt></i> is set 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>.</p><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>session</tt></i> :</span></td><td> a session.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>url</tt></i> :</span></td><td> an URL.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>from</tt></i> :</span></td><td> a RFC 3066 language tag.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>to</tt></i> :</span></td><td> a RFC 3066 language tag.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>progress_func</tt></i> :</span></td><td> a function to call when progressing, or <tt class="literal">NULL</tt>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td> data to pass to <i class="parameter"><tt>progress_func</tt></i>, or <tt class="literal">NULL</tt>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>err</tt></i> :</span></td><td> a location to report errors, or <tt class="literal">NULL</tt>. Any of the errors in
<a href="TranslateSession.html#TranslateSessionError"><span class="type">TranslateSessionError</span></a>, <a href="libtranslate-translate.html#TranslateError"><span class="type">TranslateError</span></a> or other domains may occur.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> an URL pointing to the translated web page on
success, or <tt class="literal">NULL</tt> on failure (in such case <i class="parameter"><tt>err</tt></i> is set). The
returned string should be freed when no longer needed.
</td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id2610307"></a><h2>Properties</h2><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a name="TranslateSession--max-retries"></a>"<tt class="literal">max-retries</tt>" (gint : Read / Write / Construct)</span></td><td><p>The maximum number of times to retry a translation of the same chunk (-1 for unlimited).</p></td></tr><tr><td><span class="term"><a name="TranslateSession--max-threads"></a>"<tt class="literal">max-threads</tt>" (guint : Read / Write / Construct)</span></td><td><p>The maximum number of translation threads to use.</p></td></tr><tr><td><span class="term"><a name="TranslateSession--pairs"></a>"<tt class="literal">pairs</tt>" (gpointer : Read)</span></td><td><p>The list of pairs this session supports.</p></td></tr><tr><td><span class="term"><a name="TranslateSession--services"></a>"<tt class="literal">services</tt>" (gpointer : Read / Write / Construct)</span></td><td><p>The list of services used by this session.</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="TranslateService.html"><b><< TranslateService</b></a></td><td align="right"><a accesskey="n" href="libtranslate-translate-util.html"><b>translate-util >></b></a></td></tr></table></body></html>
|