source: trunk/third/gettext/README.gemtext @ 16931

Revision 16931, 19.9 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16930, which included commits to RCS files with non-trunk default branches.
Line 
1$Revision: 1.1.1.2 $
2$Date: 2002-01-21 21:38:03 $
320
4!!! README for gemtext.  !!!
5If you think the above mentioned date is old check out
6http://stud.uni-sb.de/~gufl0000/atari/gemtext.  You will find the latest
7version there.  You will also find links to ftp sites from where you can
8download gemtext via anonymous ftp.
9
10See the file INSTALL for installing gemtext.
11See the file COPYING for licensing.
12See the file NEWS for information that is not covered by either this file
13or the provided manual pages.  All information concerning features of
14gemtext included in any text file that comes along with this package is
15subject to change without notice!
16
17==========================================================================
18
19This is the gemtext package.  The gemtext package offers standardized i18n
20(internationalization) features for GEM programs.  The package is intended
21to help programmers to internationalize their programs.  If you aren't a
22programmer you might want to read the file ABOUT-NLS to get an idea of
23national language support.  But you won't need gemtext.
24
25GEM is a registered trademark of Digital Research Company.  GEM is mainly
26used on Atari computers or the various emulations available today on other
27platforms.  You can also find the so-called PC-GEM for IBM compatible
28machines.  If you neither use an Atari nor emulate the Atari's OS you
29won't need gemtext too.  Still it might be a good idea to have a look at
30the file ABOUT-NLS.
31
32All programs and libraries contained in this package will work on their
33own, only depending on some executables and libraries that can be found in
34most Unix-like environments.  Yet, you will only benefit from gemtext if
35you have the GNU gettext package or another internationalization package
36that can be compared with gettext already installed. You will find the
37latest version of GNU gettext at
38
39  ftp://ftp.gnu.org/pub/gnu
40
41It compiles without any problems with the GNU C-compiler and MiNTLib PL46.
42(Well, there's a little problem:  If your msgfmt keeps on crashing with a
43bus error try to replace the module obstack.o in your MiNTLib with the
44obstack.c that comes along with GNU gettext.  But this is a bug in the
45MiNTLib and not in GNU gettext.)
46
47In the following I will refer to any computer that can make use of
48xgemtext as 'Atari'.  I also expect you to be familiar with the C
49programming language and with the well known data structures and function
50calls that are necessary for programming GEM applications.
51
52He, she, they... Quote from the gettext info file:
53        "In this manual, we use *he* when speaking of the programmer or
54        maintainer, *she* when speaking of the translator, and *they* when
55        speaking of the installers or end users of the translated program.
56        This is only a convenience for clarifying the documentation.  It
57        is *absolutely* not meant to imply that some roles are more
58        appropriate to males or females.  Besides, as you might guess, GNU
59        `gettext' is meant to be useful for people using computers,
60        whatever their sex, race, religion or nationality!"
61
62Last but not least:  xgemtext is written in C++.  Hence you will need a
63C++ compiler to compile the package.  GNU C++ is a good choice if you
64don't already have one.  If you don't have the system resources to run the
65compiler you will have to try to get an already compiled version.  Good
66news:  The library (which is the more important part of the gemtext
67package) is entirely written in plain C to allow easy porting to different
68compiler systems.
69
70
71
72CONTENTS
73========
74        1. Why gemtext?
75        2. Alternatives for i18n
76        3. How to use the GNU gettext package
77        4. How to use the gemtext package
78        5. The library rintl
79        6. Charsets: Atari versus ISO Latin1
80        7. Miscellanea
81
82
83
841. Why gemtext?
85===============
86
87The Atari's GUI (Graphical User Interface) offers possibilities for
88native language support for a long time already.  All necessary graphical
89data and text for the user interface is usually kept in a so-called
90resource file.  For example the program foobar.app will normally look for
91the resource file foobar.rsc in the same directory.  A programmer aware of
92i18n will usually provide several of these resource file each of them
93containing the entire data in different languages,  called e. g. en.rsc,
94fr.rsc, it.rsc and so on.  The users have to rename the particular
95resource file in their language to foobar.rsc and the program will still
96behave the same but will display its messages in the chosen language.
97
98This procedere is suboptimal for various reasons.
99
100-  The most obvious one is that you keep loads of redundant data in the
101   extra provided resouce files.  Usually the strings in the resource
102   files occupy very little space in comparison to the graphical data.
103
104-  GEM applications usually expect their resource files to reside at a
105   fixed location and to have a fixed name.  Hence, in a multi-user
106   environment you have to choose one particular language for each
107   application or you have to keep different copies of both your resource
108   and other data files.
109
110-  Once you have decided to include your resources into your source code
111   you have to say goodbye to the idea of i18n.
112
113-  Probably the most important disadvantage of the current system is the
114   effort you have to take in updating your applications.  Whenever you
115   have changed the tree structure in your resource file you will have to
116   edit every other resource file immediately if you do the translation
117   yourself.  If you let somebody else do your translations she will have
118   enormous difficulties.  She will have to click through the entire
119   resource tree, taking care not to change the data structures
120   unwillingly, and picking out the texts that have changed.  If you
121   haven't found some trickier system it is probably easier to restart the
122   translation from the beginning.
123
124-  Whenever your application has to display a message you have to edit
125   your resource file even for little ones like:
126
127     form_alert (1, "[1][ Memory exhausted! ][ Damned ]");
128
129   Every string that has to be translated has to appear in the resource
130   file.  Considering that most resource file formats are restricted to 64
131   kB of length and that most GEM libraries can handle only one single
132   resource file this is often a severe restriction in the design of the
133   GUI.
134
135
136
1372. Alternatives for i18n
138========================
139
140As far as programs are concerned that have to be run via a command line
141interpreter, there is already a portable, standardized system for message
142internationalization, the GNU gettext package. It offers tools for
143preparing all kinds of source files for i18n, tools that help both the
144programmer and translator to keep track of updated versions (and the
145maintainers, too) and it comes along with a free C library that gives
146access to the translated messages at runtime of the program depending on
147the setting of documented environment variables.
148
149You should get a copy of the GNU gettext package now.  Yet, if you are too
150curious to download it at once, just go ahead but you might want to reread
151this file later as it refers to information that is available only with
152the GNU gettext package.
153
154The gemtext package should also be useful with NLS-packages (Native
155Language Support) other than GNU gettext to the degree that GNU gettext
156itself is compatible with other standardized packages.  Yet, it has been
157only tested with GNU gettext as it is the only available one for Atari.
158
159
160
1613. How to use the GNU gettext package
162=====================================
163
164Forget about the whole GUI thing for a short while to get roughly an idea
165of programming with the GNU gettext package.  We'll come back to the GUI
166shortly.
167
168NOTE: This section isn't meant to be an exhaustive description of the GNU
169gettext package.  It is intended to give you an overview.  If you already
170know the GNU gettext package you might safely skip this section.
171
172Localizing messages in a C program is very easily done.  At first you need
173some (usually three) lines of extra code to tell the NLS library functions
174where to find the translated messages.  Then you have to go through your
175code and decide for every string whether you want to get it translated or
176not. Strings that should be translated have to be embedded in a function
177call to gettext ().  Thus instead of writing:
178
179   printf ("Hello world!\n");
180
181you would now write
182
183   printf (gettext ("Hello world!\n"));
184
185When you're fed up with typing g-e-t-t-e-x-t over and over again you will
186follow the habit of most of your colleagues and
187
188   #define _(s) gettext (s)
189
190well knowing that now only three extra keystrokes will make the rest of
191the world happy.
192
193Very handy, very easy, isn't it?  Unfortunately it doesn't work if you use
194strings for example in initialized structures or arrays.  Really? Just to
195make sure that you don't abandon the whole thing already, I will tell you
196a secret:  It still works!  Read the gettext info file and follow the
197nodes Sources -> Special cases.
198
199After having marked all translatable strings in your sources you will want
200to extract them for translation by
201
202   xgettext *.c
203
204producing a file messages.po that contains both the original strings and
205space for the translations.  After the file being translated you will
206compile it into a binary by a call to the program msgfmt.  This binary
207file will then usually be moved to
208
209   /usr/(local/)share/locale/de/LC_MESSAGES/foobar.mo
210
211provided that your program has been translated into German ('de' is the
212ISO-639 2-letter country code for Germany).
213
214Now you set one of the envariables LANGUAGE, LANG or LC_ALL to 'de' and
215recompile your sources.  Your linker will then complain about the
216reference to 'gettext' not being resolved and you will fix the problem by
217linking the program with the 'intl'-library that comes along with gettext
218(and gemtext, too).  Surprise, surprise!  Your program has learned to say
219hello to the world in yet another language.
220
221After long and satisfying experiences with your chef-d'oeuvre you might
222feel that it is not enough to say hello to the world.  You want to say
223hello to the whole universe, too.  So what now?  Redo the whole thing?
224No!  You simply update your sources and extract a new messages file.
225Before translating the file entirely again you should have msgmerge have a
226glimpse at both the original and the updated file.  The program msgmerge
227is very clever and will probably guess what you have done.  It will
228produce a new .po file that will already contain the strings you have
229translated the last time.  It will also not cast away those strings that
230you do not care to translate any longer.  It will comment them out
231instead, thus allowing you to change your mind again later.  This feature
232is also very handy for corrected misspellings or minor modifications to
233strings.  If msgmerge encounters such a case it will mark the maybe
234incorrect translation it guesses to be best as a "fuzzy" translation.  If
235you agree with msgmerge, simply remove the "fuzzy" comment.
236
237Well, that's it in brief.  Again, if you want to understand the GNU
238gettext package in its whole powerfulness you can't help reading the
239documentation.
240
241
242
2434. How to use the gemtext package
244=================================
245
246Probably you have already seen that it's no longer necessary to put
247strings for alert boxes or other free strings in your resource files.
248What has worked with printf will work with form_alert, too.
249
250And what about resources integrated in your source files?  Why not?  Most
251resource construction sets offer the possibility to produce a C source
252file as output and running a simple awk script on this file will already
253do the whole job for you.  (An important advantage of integrated resources
254is that you're not restricted to 64 kB anymore).
255
256But if you don't bother to write all the routines to fix adresses of
257object trees and so on you will estimate the help of xgemtext from this
258package.
259
260Running
261
262   xgemtext *.rsc
263
264in your source directory will extract all strings from your resource files
265placing them in a file messages.c looking more or less like this:
266
267   /* This file was automatically produced by xgemtext <version> */
268
269   #ifndef gettext_noop
270   #define gettext_noop(s) (s)
271   #endif
272
273   const char* volatile nls_rsc_strings[] = {
274           gettext_noop (" Foobar"),
275           gettext_noop (" File"),
276           gettext_noop (" Options"),
277           gettext_noop (" About Foobar..."),
278           gettext_noop (" Open"),
279           ... /* All other strings in your resource.  */
280           0L
281   }
282
283It looks like a real C source file and it actually is one.  Yet, usually
284you will never compile it nor link the corresponding object file.  But you
285never know...
286
287Various options control xgemtext's behavior while extracting the strings
288from your resources, see the manual page for detailed information.  Of
289course it does not extract only strings from objects of type G_TEXT,
290G_STRING etc. but from all kinds of objects containing text, including
291icons and bitmaps.
292
293So what's the purpose of messages.c if not compiling?  You can run
294it (together with your other sources) through xgettext and now you have
295your resource strings in a .po file that can be processed with all the
296tools from the GNU gettext package.
297
298
299
3005. The library rintl
301====================
302
303Your resource file hasn't been patched by xgemtext.  So, how to get the
304translated strings into the objects where they should go?  You load your
305resource as usual.  Now you simply have to take the habit to call
306gettree() for each object tree after fixing the object addresses via
307rsrc_gaddr(). The library function gettree() will walk thru the specified
308object tree replacing each pointer to a string with a pointer to the
309translated versions.  It will also modify some members of the internal
310data structures (string length etc.) to the appropriate values.
311
312For simple objects this is all that you have to do.  For more complicated
313ones translating the strings might leave your carefully designed objects a
314mess, beginning with menues.  Remember that all string lengths may have
315been arbitrarily changed, resulting in objects that might hide each other
316or ugly looking gaps between objects that were meant to be close to each
317other.
318
319You will find numerous functions in the library rintl that will try to
320bring your objects back to a tolerable outer appearance again, each of
321them being called rnl<object_type>().  You will also find a function
322called rnltree() that will try to do the job for entire object trees.  You
323can control the behavior of these adapt functions in numerous ways that
324should meet as many requirements as possible.  You can specify spaces to
325be left between objects, margins to the tree borders, minimum widths of
326button objects and so on.  You can also tell the functions not to walk
327thru the whole object tree but stopping at a certain level, thus allowing
328you to process different parts of your objects each with individual values
329for the control flags and variables.
330
331Menus usually require special treatment.  rnlmenu() will usually to the
332job in a satisfying manner.
333
334As you might guess the result still can't be perfect.  Your objects might
335need a little (or a whole lot of) fine tuning after being translated.
336Special care is also expected from the translator.  She has to follow some
337simple rules while doing her job.  You yourself, the programmer, should
338follow some rules when designing your object trees.  The rnltree()
339function will work best if it finds all object children in rows and
340columns of constant height. This can be easily achieved by putting object
341children belonging logically together into visible or invisible boxes.
342
343For each library function you will find a manual page describing its
344functionality in detail.
345
346In the subdirectory ``example'' after building the binaries you will find
347a simple example program showing all this in a simple manner.  Set the
348envariable LANGUAGE to one of the values de (German), it (Italian), fr
349(French), nl (Dutch), ga (Irish) or pt (portuguese) to select
350your preferred language.  Setting the envariable to an unknown
351value will make the example program choose the default values
352``C'' (in this case English).
353
354Select the menu entry ``International...'' to see a simple text displayed
355in your selected language.  The entry ``Language...'' might allow you to
356change the language even at runtime but this depends on the existence of
357the putenv() function in your standard C library.  If putenv() is not
358found the entry will be disabled. You have to change the language on the
359command line.
360
361In the ``Options'' menu you can follow the metamorphosis of a GEM dialog,
362first without any treatment, then after a call to rnltree() and finally
363after some additional beauty cures.  See the source and the manual
364pages rnltree(3) and rnlpush(3) for details.
365
366
367
3686. Charsets: Atari versus ISO Latin1
369====================================
370
371There's a dilemma with the i18n thing.  On other platforms (especially of
372the workstation sector) you can not only localize the language but also
373the charset to utilize.  AFAIK there's no C library available that allows
374you to do so on Atari.
375
376A couple of years ago there was but one choice for a charset in the Atari
377sector, the charset of the Atari's built-in system font.  Now more and
378more Atari users have switched to the universally used ISO Latin1 charset
379also known as iso-8859-1, especially when using a command line interpreter.
380If you use already internationalized GNU packages you will come across
381this charset, too.  (Note that both ISO Latin1 and the Atari charset are
382intended for use with western european languages, the Atari's charset
383to a certain extent also for Hebrew and Greek.  Hence the following refers
384only to those languages).
385
386I have chosen the following way:  As it is very unlikely that you use an
387ISO Latin1 charset with GEM, the files containing the messages for the
388example program - which has a GUI - have to be read with the Atari
389charset. But these files shouldn't go into your locale directory.  The
390whole thing is provided as an example and should stay where it is (i. e.
391it isn't installed).
392
393For xgemtext you have the choice. If you use an ISO Latin1 font (as you
394should do) simply follow the instructions in ABOUT-NLS.  If you insist on
395using a font with an Atari codeset set the environment variable LANGUAGE
396(or LC_ALL or LC_xxx) to <ll>.atarist where <ll> should specify the
397language you want to use.  When installing xgemtext the appropriate
398directories in your locale directory get created.  They will be called
399<localedir>/<ll>.atarist/LC_MESSAGES.
400
401
4027. Miscellanea
403==============
404
405Now something that might leave you a little uneasy:  The translating
406project relies on the original programs being written in English.  Say you
407have written your program in Rhaeto-Romance and you want to have it
408translated into Irish.  Well, the diligent translator from the Aron
409Islands is lucky enough to understand English and she probably won't
410bother to learn Rhaeto-Romance.  The only possibility to solve the problem
411is to agree upon one base language and this language is English.  If you
412have made it until here through this document I'm sure you will manage to
413write the messages in your sources and resources in English, too.
414
415Of course you will have to explain your users how to benefit from the new
416i18n features of your program.  Include the file ABOUT-NLS that is part
417of the GNU gettext distribution.  This will tell your users the
418necessary measures to take.
419
420You should also include a copy of the file ATARI.NLS in your sources.
421This file is intended to be read by translators.  They will find some
422useful hints for translating messages for GEM programs.
423
424Note that gemtext is *not* part of the GNU project!  Bug reports,
425comments, compliments should be sent to the author, flames and criticism
426to /dev/null.  Please also note that everything you find in the directory
427intl *is* part of the GNU gettext package.  Thus, any comments concerning
428files in this subdirectory should be directed to the maintainer of the GNU
429gettext package.  There are some other files that consist partly or
430entirely of copyrighted material by the Free Software Foundation.  If in
431doubt check the header texts.
432
433Hope you have fun with gemtext!
434
435Guido Flohr <gufl0000@stud.uni-sb.de>.
Note: See TracBrowser for help on using the repository browser.