1
<?xml version="1.0" encoding="ISO-8859-1"?>
6
====================================================================
8
====================================================================
11
<module name="gettext">
12
<short>Unit implementing resource string translation using gettext files</short>
14
The <file>gettext</file> unit can be used to hook into the resource string mechanism
15
of Free Pascal to provide translations of the resource strings, based on the
16
GNU gettext mechanism. The unit provides a class (<link id="TMOFile"/>) to read
17
the <file>.mo</file> files with localizations for various languages. It
18
also provides a couple of calls to translate all resource strings in an
19
application based on the translations in a <file>.mo</file> file.
22
<!-- unresolved type reference Visibility: default -->
23
<element name="SysUtils">
24
<short>Exception and string formatting support.</short>
27
<!-- unresolved type reference Visibility: default -->
28
<element name="Classes">
29
<short>Stream support</short>
32
<!-- constant Visibility: default -->
33
<element name="MOFileHeaderMagic">
34
<short>file header bytes indicating a <file>.mo</file> file.</short>
36
This constant is found as the first integer in a <file>.mo</file>
39
<link id="TMOFileHeader"/>
43
<!-- record type Visibility: default -->
44
<element name="TMOFileHeader">
45
<short>Structure found at the head of a <file>.mo</file> file.</short>
47
This structure describes the structure of a <file>.mo</file> file with
52
<!-- variable Visibility: default -->
53
<element name="TMOFileHeader.magic">
54
<short>Magic constant, should equal <link id="#fcl.gettext.MOFileHeaderMagic">MOFileHeaderMagic</link>.</short>
57
<!-- variable Visibility: default -->
58
<element name="TMOFileHeader.revision">
59
<short>File revision</short>
62
<!-- variable Visibility: default -->
63
<element name="TMOFileHeader.nstrings">
64
<short>Number of string pairs in the file</short>
67
<!-- variable Visibility: default -->
68
<element name="TMOFileHeader.OrigTabOffset">
69
<short>Offset of the original strings description table.</short>
72
<!-- variable Visibility: default -->
73
<element name="TMOFileHeader.TransTabOffset">
74
<short>Offset of the translated strings description table.</short>
77
<!-- variable Visibility: default -->
78
<element name="TMOFileHeader.HashTabSize">
79
<short>Size of hashing table.</short>
82
<!-- variable Visibility: default -->
83
<element name="TMOFileHeader.HashTabOffset">
84
<short>Offset of hashing table.</short>
87
<!-- record type Visibility: default -->
88
<element name="TMOStringInfo">
89
<short>Structure describing string</short>
91
This record is one element in the string tables describing the original and
92
translated strings. It describes the position and length of the string. The
93
location of these tables is stored in the <link id="TMOFileHeader"/> record
94
at the start of the file.
97
<link id="TMOFileHeader"/>
101
<!-- variable Visibility: default -->
102
<element name="TMOStringInfo.length">
103
<short>Length of the string</short>
106
<!-- variable Visibility: default -->
107
<element name="TMOStringInfo.offset">
108
<short>Offset in the file</short>
111
<!-- array type Visibility: default -->
112
<element name="TMOStringTable">
113
<short>Array of <link id="#fcl.gettext.TMOStringInfo">TMOStringInfo</link> records.</short>
115
<var>TMOStringTable</var> is an array type containing <link id="TMOStringInfo"/> records.
116
It should never be used directly, as it would occupy too much memory.
119
<link id="PMOStringTable"/>
123
<!-- pointer type Visibility: default -->
124
<element name="PMOStringTable">
125
<short>Pointer to a <link id="#fcl.gettext.TMOStringTable">TMOStringTable</link> array.</short>
128
<!-- array type Visibility: default -->
129
<element name="TLongWordArray">
130
<short>Array of <var>longword</var> elements.</short>
132
<var>TLongWordArray</var> is an array used to define the <link id="PLongWordArray"/> pointer.
133
A variable of type <var>TLongWordArray</var> should never be directly
134
declared, as it would occupy too much memory. The <var>PLongWordArray</var> type can be used
135
to allocate a dynamic number of elements.
138
<link id="PLongWordArray"/>
142
<!-- pointer type Visibility: default -->
143
<element name="PLongWordArray">
144
<short>Pointer to a <link id="#fcl.gettext.TLongWordArray">TLongWordArray</link> array.</short>
147
<!-- array type Visibility: default -->
148
<element name="TPCharArray">
149
<short>Array of <var>PChar</var> elements</short>
151
<var>TLongWordArray</var> is an array used to define the <link id="PPCharArray"/> pointer.
152
A variable of type <var>TPCharArray</var> should never be directly declared, as it would
153
occupy too much memory. The <var>PPCharArray</var> type can be used to allocate a dynamic
157
<link id="PPCharArray"/>
161
<!-- pointer type Visibility: default -->
162
<element name="PPCharArray">
163
<short>Pointer to a <link id="#fcl.gettext.TPCharArray">TPCharArray</link> array.</short>
167
********************************************************************
169
********************************************************************
172
<!-- object Visibility: default -->
173
<element name="TMOFile">
174
<short>Class providing access to a <file>.mo</file> file.</short>
176
<var>TMOFile</var> is a class providing easy access to a <file>.mo</file> file.
177
It can be used to translate any of the strings that reside in the
178
<file>.mo</file> file. The internal structure of the <file>.mo</file> is
183
<!-- constructor Visibility: public -->
184
<element name="TMOFile.Create">
185
<short>Create a new instance of the <var>TMOFile</var> class.</short>
188
<var>Create</var> creates a new instance of the <var>MOFile</var> class.
189
It opens the file <var>AFileName</var> or the stream <var>AStream</var>.
190
If a stream is provided, it should be seekable.
193
The whole contents of the file is read into memory during the
194
<var>Create</var> call. This means that the stream is no longer
195
needed after the <var>Create</var> call.
199
If the named file does not exist, then an exception may be raised. If the
200
file does not contain a valid <link id="TMOFileHeader"/> structure, then
201
an <link id="EMOFileError"/> exception is raised.
204
<link id="TMOFile.Destroy"/>
208
<!-- argument Visibility: default -->
209
<element name="TMOFile.Create.AFilename">
210
<short>File to open.</short>
213
<!-- argument Visibility: default -->
214
<element name="TMOFile.Create.AStream">
215
<short>Contents of a .mo file.</short>
218
<!-- destructor Visibility: public -->
219
<element name="TMOFile.Destroy">
220
<short>Removes the <var>TMOFile</var> instance from memory</short>
222
<var>Destroy</var> cleans the internal structures with the contents of the
223
<file>.mo</file>. After this the <var>TMOFile</var> instance is removed from
227
<link id="TMOFile.Create"/>
231
<!-- function Visibility: public -->
232
<element name="TMOFile.Translate">
233
<short>Translate a string</short>
236
<var>Translate</var> translates the string <var>AOrig</var>.
237
The string should be in the .mo file as-is. The string can be given as a
238
plain string, as a <var>PChar</var> (with length <var>ALen</var>). If the
239
hash value (<var>AHash</var>) of the string is not given, it is calculated.
242
If the string is in the <var>.mo</var> file, the translated string is
243
returned. If the string is not in the file, an empty string is returned.
251
<!-- function result Visibility: default -->
252
<element name="TMOFile.Translate.Result">
253
<short>Translated string.</short>
256
<!-- argument Visibility: default -->
257
<element name="TMOFile.Translate.AOrig">
258
<short>String to translate.</short>
261
<!-- argument Visibility: default -->
262
<element name="TMOFile.Translate.ALen">
263
<short>Length of the original string.</short>
266
<!-- argument Visibility: default -->
267
<element name="TMOFile.Translate.AHash">
268
<short>Hash value of the original string.</short>
272
********************************************************************
273
#fcl.gettext.EMOFileError
274
********************************************************************
277
<!-- object Visibility: default -->
278
<element name="EMOFileError">
279
<short>Exception raised in case of an error.</short>
281
<var>EMOFileError</var> is raised in case an <link id="TMOFile"/> instance
282
is created with an invalid <file>.mo</file>.
289
<!-- procedure Visibility: default -->
290
<element name="GetLanguageIDs">
291
<short>Return the current language IDs</short>
293
<var>GetLanguageIDs</var> returns the current language IDs (an ISO string) as
294
returned by the operating system. On windows, the <var>GetUserDefaultLCID</var>
295
and <var>GetLocaleInfo</var> calls are used. On other operating systems,
296
the <var>LC_ALL</var>, <var>LC_MESSAGES</var> or <var>LANG</var> environment
297
variables are examined.
301
<!-- argument Visibility: default -->
302
<element name="GetLanguageIDs.Lang">
303
<short>Primary language</short>
306
<!-- argument Visibility: default -->
307
<element name="GetLanguageIDs.FallbackLang">
308
<short>Secondary language</short>
311
<!-- procedure Visibility: default -->
312
<element name="TranslateResourceStrings">
313
<short>Translate the resource strings of the application.</short>
315
<var>TranslateResourceStrings</var> translates all the resource strings
316
in the application based on the values in the <file>.mo</file> file
317
<var>AFileName</var> or <var>AFile</var>.
318
The procedure creates an <link id="TMOFile"/> instance to
319
read the <file>.mo</file> file if a filename is given.
322
If the file does not exist or is an invalid <file>.mo</file> file.
325
<link id="TranslateUnitResourceStrings"/>
330
<!-- argument Visibility: default -->
331
<element name="TranslateResourceStrings.AFile">
332
<short><var>TMOfile</var> instance with translated strings.</short>
335
<!-- argument Visibility: default -->
336
<element name="TranslateResourceStrings.AFilename">
337
<short>Name of <file>.mo</file> file with translated strings</short>
340
<!-- procedure Visibility: default -->
341
<element name="TranslateUnitResourceStrings">
342
<short>Translate the resource strings of a unit.</short>
344
<var>TranslateUnitResourceStrings</var> is identical in function to
345
<link id="TranslateResourceStrings"/>, but translates the strings of a
346
single unit (<var>AUnitName</var>) which was used to compile the
347
application. This can be more convenient, since the resource string files
348
are created on a unit basis.
351
<link id="TranslateResourceStrings"/>
356
<!-- argument Visibility: default -->
357
<element name="TranslateUnitResourceStrings.AUnitName">
358
<short>Name of the unit whose strings should be translated.</short>
361
<!-- argument Visibility: default -->
362
<element name="TranslateUnitResourceStrings.AFile">
363
<short><var>TMOFile</var> instance with translated strings.</short>
366
<!-- argument Visibility: default -->
367
<element name="TranslateUnitResourceStrings.AFilename">
368
<short>Name of <file>.mo</file> file with translated strings</short>
371
</module> <!-- gettext -->
374
</fpdoc-descriptions>