summaryrefslogtreecommitdiff
path: root/fpcdocs/gettext.xml
blob: cb4efad1f702bb0938904062351f9fb4139456d6 (plain)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?xml version="1.0" encoding="ISO-8859-1"?>
<fpdoc-descriptions>
<package name="fcl">

<!--
  ====================================================================
    gettext
  ====================================================================
-->

<module name="gettext">
<short>Unit implementing resource string translation using gettext files</short>
<descr>
<p>The <file>gettext</file> unit can be used to hook into the resource string mechanism
of Free Pascal to provide translations of the resource strings, based on the
GNU gettext mechanism. The unit provides a class (<link id="TMOFile"/>) to read 
the <file>.mo</file> files with localizations for various languages. It
also provides a couple of calls to translate all resource strings in an
application based on the translations in a <file>.mo</file> file.</p>
</descr>

<!-- unresolved type reference Visibility: default -->
<element name="SysUtils">
<short>Exception and string formatting support.</short>
</element>

<!-- unresolved type reference Visibility: default -->
<element name="Classes">
<short>Stream support</short>
</element>

<!-- constant Visibility: default -->
<element name="MOFileHeaderMagic">
<short>file header bytes indicating a <file>.mo</file> file.</short>
<descr>
This constant is found as the first integer in a <file>.mo</file>
</descr>
<seealso>
<link id="TMOFileHeader"/>
</seealso>
</element>

<!-- record type Visibility: default -->
<element name="TMOFileHeader">
<short>Structure found at the head of a <file>.mo</file> file.</short>
<descr>
This structure describes the structure of a <file>.mo</file> file with
string localizations.
</descr>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.magic">
<short>Magic constant, should equal <link id="#fcl.gettext.MOFileHeaderMagic">MOFileHeaderMagic</link>.</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.revision">
<short>File revision</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.nstrings">
<short>Number of string pairs in the file</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.OrigTabOffset">
<short>Offset of the original strings description table.</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.TransTabOffset">
<short>Offset of the translated strings description table.</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.HashTabSize">
<short>Size of hashing table.</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOFileHeader.HashTabOffset">
<short>Offset of hashing table.</short>
</element>

<!-- record type Visibility: default -->
<element name="TMOStringInfo">
<short>Structure describing string</short>
<descr>
This record is one element in the string tables describing the original and
translated strings. It describes the position and length of the string. The
location of these tables is stored in the <link id="TMOFileHeader"/> record
at the start of the file.
</descr>
<seealso>
<link id="TMOFileHeader"/>
</seealso>
</element>

<!-- variable Visibility: default -->
<element name="TMOStringInfo.length">
<short>Length of the string</short>
</element>

<!-- variable Visibility: default -->
<element name="TMOStringInfo.offset">
<short>Offset in the file</short>
</element>

<!-- array type Visibility: default -->
<element name="TMOStringTable">
<short>Array of <link id="#fcl.gettext.TMOStringInfo">TMOStringInfo</link> records.</short>
<descr>
<var>TMOStringTable</var> is an array type containing <link id="TMOStringInfo"/> records.
It should never be used directly, as it would occupy too much memory.
</descr>
<seealso>
<link id="PMOStringTable"/>
</seealso>
</element>

<!-- pointer type Visibility: default -->
<element name="PMOStringTable">
<short>Pointer to a <link id="#fcl.gettext.TMOStringTable">TMOStringTable</link> array.</short>
</element>

<!-- array type Visibility: default -->
<element name="TLongWordArray">
<short>Array of <var>longword</var> elements.</short>
<descr>
<var>TLongWordArray</var> is an array used to define the <link id="PLongWordArray"/> pointer.
A variable of type <var>TLongWordArray</var> should never be directly
declared, as it would occupy too much memory.  The <var>PLongWordArray</var> type can be used 
to allocate a dynamic number of elements.
</descr>
<seealso>
<link id="PLongWordArray"/>
</seealso>
</element>

<!-- pointer type Visibility: default -->
<element name="PLongWordArray">
<short>Pointer to a <link id="#fcl.gettext.TLongWordArray">TLongWordArray</link> array.</short>
</element>

<!-- array type Visibility: default -->
<element name="TPCharArray">
<short>Array of <var>PChar</var> elements</short>
<descr>
<var>TLongWordArray</var> is an array used to define the <link id="PPCharArray"/> pointer.
A variable of type <var>TPCharArray</var> should never be directly declared, as it would 
occupy too much memory. The <var>PPCharArray</var> type can be used to allocate a dynamic 
number of elements.
</descr>
<seealso>
<link id="PPCharArray"/>
</seealso>
</element>

<!-- pointer type Visibility: default -->
<element name="PPCharArray">
<short>Pointer to a <link id="#fcl.gettext.TPCharArray">TPCharArray</link> array.</short>
</element>

<!--
  ********************************************************************
    #fcl.gettext.TMOFile
  ********************************************************************
-->

<!-- object Visibility: default -->
<element name="TMOFile">
<short>Class providing access to a <file>.mo</file> file.</short>
<descr>
<var>TMOFile</var> is a class providing easy access to a <file>.mo</file> file.
It can be used to translate any of the strings that reside in the
<file>.mo</file> file. The internal structure of the <file>.mo</file> is
completely hidden.
</descr>
</element>

<!-- constructor Visibility: public -->
<element name="TMOFile.Create">
<short>Create a new instance of the <var>TMOFile</var> class.</short>
<descr>
<p>
<var>Create</var> creates a new instance of the <var>MOFile</var> class. 
It opens the file <var>AFileName</var> or the stream <var>AStream</var>.
If a stream is provided, it should be seekable.
</p>
<p>
The whole contents of the file is read into memory during the
<var>Create</var> call. This means that the stream is no longer 
needed after the <var>Create</var> call. 
</p>
</descr>
<errors>
If the named file does not exist, then an exception may be raised. If the
file does not contain a valid <link id="TMOFileHeader"/> structure, then 
an <link id="EMOFileError"/> exception is raised.
</errors>
<seealso>
<link id="TMOFile.Destroy"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="TMOFile.Create.AFilename">
<short>File to open.</short>
</element>

<!-- argument Visibility: default -->
<element name="TMOFile.Create.AStream">
<short>Contents of a .mo file.</short>
</element>

<!-- destructor Visibility: public -->
<element name="TMOFile.Destroy">
<short>Removes the <var>TMOFile</var> instance from memory</short>
<descr>
<var>Destroy</var> cleans the internal structures with the contents of the
<file>.mo</file>. After this the <var>TMOFile</var> instance is removed from
memory.
</descr>
<seealso>
<link id="TMOFile.Create"/>
</seealso>
</element>

<!-- function Visibility: public -->
<element name="TMOFile.Translate">
<short>Translate a string</short>
<descr>
<p>
<var>Translate</var> translates the string <var>AOrig</var>. 
The string should be in the .mo file as-is. The string can be given as a
plain string, as a <var>PChar</var> (with length <var>ALen</var>). If the
hash value (<var>AHash</var>) of the string is not given, it is calculated.
</p>
<p>
If the string is in the <var>.mo</var> file, the translated string is
returned. If the string is not in the file, an empty string is returned.
</p>
</descr>
<errors>
None.
</errors>
</element>

<!-- function result Visibility: default -->
<element name="TMOFile.Translate.Result">
<short>Translated string.</short>
</element>

<!-- argument Visibility: default -->
<element name="TMOFile.Translate.AOrig">
<short>String to translate.</short>
</element>

<!-- argument Visibility: default -->
<element name="TMOFile.Translate.ALen">
<short>Length of the original string.</short>
</element>

<!-- argument Visibility: default -->
<element name="TMOFile.Translate.AHash">
<short>Hash value of the original string.</short>
</element>

<!--
  ********************************************************************
    #fcl.gettext.EMOFileError
  ********************************************************************
-->

<!-- object Visibility: default -->
<element name="EMOFileError">
<short>Exception raised in case of an error.</short>
<descr>
<var>EMOFileError</var> is raised in case an <link id="TMOFile"/> instance
is created with an invalid <file>.mo</file>.
</descr>
<seealso>
<link id="TMOFile"/>
</seealso>
</element>

<!-- procedure Visibility: default -->
<element name="GetLanguageIDs">
<short>Return the current language IDs</short>
<descr>
<var>GetLanguageIDs</var> returns the current language IDs (an ISO string) as 
returned by the operating system. On windows, the <var>GetUserDefaultLCID</var> 
and <var>GetLocaleInfo</var> calls are  used. On other operating systems,
the <var>LC_ALL</var>, <var>LC_MESSAGES</var> or <var>LANG</var> environment
variables are examined.
</descr>
</element>

<!-- argument Visibility: default -->
<element name="GetLanguageIDs.Lang">
<short>Primary language</short>
</element>

<!-- argument Visibility: default -->
<element name="GetLanguageIDs.FallbackLang">
<short>Secondary language</short>
</element>

<!-- procedure Visibility: default -->
<element name="TranslateResourceStrings">
<short>Translate the resource strings of the application.</short>
<descr>
<var>TranslateResourceStrings</var> translates all the resource strings 
in the application based on the values in the <file>.mo</file> file 
<var>AFileName</var> or <var>AFile</var>. 
The procedure creates an <link id="TMOFile"/> instance to
read the <file>.mo</file> file if a filename is given.
</descr>
<errors>
If the file does not exist or is an invalid <file>.mo</file> file.
</errors>
<seealso>
<link id="TranslateUnitResourceStrings"/>
<link id="TMOFile"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="TranslateResourceStrings.AFile">
<short><var>TMOfile</var> instance with translated strings.</short>
</element>

<!-- argument Visibility: default -->
<element name="TranslateResourceStrings.AFilename">
<short>Name of <file>.mo</file> file with translated strings</short>
</element>

<!-- procedure Visibility: default -->
<element name="TranslateUnitResourceStrings">
<short>Translate the resource strings of a unit.</short>
<descr>
<var>TranslateUnitResourceStrings</var> is identical in function to
<link id="TranslateResourceStrings"/>, but translates the strings of a
single unit (<var>AUnitName</var>) which was used to compile the 
application. This can be more convenient, since the resource string files
are created on a unit basis.
</descr>
<seealso>
<link id="TranslateResourceStrings"/>
<link id="TMOFile"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="TranslateUnitResourceStrings.AUnitName">
<short>Name of the unit whose strings should be translated.</short>
</element>

<!-- argument Visibility: default -->
<element name="TranslateUnitResourceStrings.AFile">
<short><var>TMOFile</var> instance with translated strings.</short>
</element>

<!-- argument Visibility: default -->
<element name="TranslateUnitResourceStrings.AFilename">
<short>Name of <file>.mo</file> file with translated strings</short>
</element>

</module> <!-- gettext -->

</package>
</fpdoc-descriptions>