home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gettext-0.10.24-bin.lha / info / gettext.info-1 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  46KB  |  769 lines

  1. This is Info file gettext.info, produced by Makeinfo-1.64 from the
  2. input file /ade-src/fsf/gettext/doc/gettext.texi.
  3. START-INFO-DIR-ENTRY
  4. * Gettext Utilities: (gettext).        GNU gettext utilities.
  5. * gettextize: (gettext)gettextize Invocation.    Prepare a package for gettext.
  6. * msgfmt: (gettext)msgfmt Invocation.        Make MO files out of PO files.
  7. * msgmerge: (gettext)msgmerge Invocation.    Update two PO files into one.
  8. * xgettext: (gettext)xgettext Invocation.    Extract strings into a PO file.
  9. END-INFO-DIR-ENTRY
  10.    This file provides documentation for GNU `gettext' utilities.
  11.    Copyright (C) 1995 Free Software Foundation, Inc.
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided that
  17. the entire resulting derived work is distributed under the terms of a
  18. permission notice identical to this one.
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that this permission notice may be stated in a
  22. translation approved by the Foundation.
  23. File: gettext.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  24. GNU `gettext' utilities
  25. ***********************
  26. * Menu:
  27. * Introduction::                Introduction
  28. * Basics::                      PO Files and PO Mode Basics
  29. * Sources::                     Preparing Program Sources
  30. * Initial::                     Making the Initial PO File
  31. * Updating::                    Updating Existing PO Files
  32. * Binaries::                    Producing Binary MO Files
  33. * Users::                       The User's View
  34. * Programmers::                 The Programmer's View
  35. * Translators::                 The Translator's View
  36. * Maintainers::                 The Maintainer's View
  37. * Conclusion::                  Concluding Remarks
  38. * Country Codes::               ISO 639 country codes
  39.  -- The Detailed Node Listing --
  40. Introduction
  41. * Why::                         The Purpose of GNU `gettext'
  42. * Concepts::                    I18n, L10n, and Such
  43. * Aspects::                     Aspects in Native Language Support
  44. * Files::                       Files Conveying Translations
  45. * Overview::                    Overview of GNU `gettext'
  46. PO Files and PO Mode Basics
  47. * Installation::                Completing GNU `gettext' Installation
  48. * PO Files::                    The Format of PO Files
  49. * Main PO Commands::            Main Commands
  50. * Entry Positioning::           Entry Positioning
  51. * Normalizing::                 Normalizing Strings in Entries
  52. Preparing Program Sources
  53. * Triggering::                  Triggering `gettext' Operations
  54. * Mark Keywords::               How Marks Appears in Sources
  55. * Marking::                     Marking Translatable Strings
  56. * c-format::                    Telling something about the following string
  57. * Special cases::               Special Cases of Translatable Strings
  58. Making the Initial PO File
  59. * xgettext Invocation::         Invoking the `xgettext' Program
  60. * C Sources Context::           C Sources Context
  61. * Compendium::                  Using Translation Compendiums
  62. Updating Existing PO Files
  63. * msgmerge Invocation::         Invoking the `msgmerge' Program
  64. * Fuzzy Entries::               Fuzzy translated Entries
  65. * Untranslated Entries::        Untranslated Entries
  66. * Obsolete Entries::            Obsolete Entries
  67. * Modifying Translations::      Modifying Translations
  68. * Modifying Comments::          Modifying Comments
  69. * Auxiliary::                   Consulting Auxiliary PO Files
  70. Producing Binary MO Files
  71. * msgfmt Invocation::           Invoking the `msgfmt' Program
  72. * MO Files::                    The Format of GNU MO Files
  73. The User's View
  74. * Matrix::                      The Current `NLS' Matrix for GNU
  75. * Installers::                  Magic for Installers
  76. * End Users::                   Magic for End Users
  77. The Programmer's View
  78. * catgets::                     About `catgets'
  79. * gettext::                     About `gettext'
  80. * Comparison::                  Comparing the two interfaces
  81. * Using libintl.a::             Using libintl.a in own programs
  82. * gettext grok::                Being a `gettext' grok
  83. * Temp Programmers::            Temporary Notes for the Programmers Chapter
  84. About `catgets'
  85. * Interface to catgets::        The interface
  86. * Problems with catgets::       Problems with the `catgets' interface?!
  87. About `gettext'
  88. * Interface to gettext::        The interface
  89. * Ambiguities::                 Solving ambiguities
  90. * Locating Catalogs::           Locating message catalog files
  91. * Optimized gettext::           Optimization of the *gettext functions
  92. Temporary Notes for the Programmers Chapter
  93. * Temp Implementations::        Temporary - Two Possible Implementations
  94. * Temp catgets::                Temporary - About `catgets'
  95. * Temp WSI::                    Temporary - Why a single implementation
  96. * Temp Notes::                  Temporary - Notes
  97. The Translator's View
  98. * Trans Intro 0::               Introduction 0
  99. * Trans Intro 1::               Introduction 1
  100. * Discussions::                 Discussions
  101. * Organization::                Organization
  102. * Information Flow::            Information Flow
  103. Organization
  104. * Central Coordination::        Central Coordination
  105. * National Teams::              National Teams
  106. * Mailing Lists::               Mailing Lists
  107. National Teams
  108. * Sub-Cultures::                Sub-Cultures
  109. * Organizational Ideas::        Organizational Ideas
  110. The Maintainer's View
  111. * Flat and Non-Flat::           Flat or Non-Flat Directory Structures
  112. * Prerequisites::               Prerequisite Works
  113. * gettextize Invocation::       Invoking the `gettextize' Program
  114. * Adjusting Files::             Files You Must Create or Alter
  115. Files You Must Create or Alter
  116. * po/POTFILES::                 `POTFILES' in `po/'
  117. * configure.in::                `configure.in' at top level
  118. * aclocal::                     `aclocal.m4' at top level
  119. * acconfig::                    `acconfig.h' at top level
  120. * Makefile::                    `Makefile.in' at top level
  121. * src/Makefile::                `Makefile.in' in `src/'
  122. Concluding Remarks
  123. * History::                     History of GNU `gettext'
  124. * References::                  Related Readings
  125. File: gettext.info,  Node: Introduction,  Next: Basics,  Prev: Top,  Up: Top
  126. Introduction
  127. ************
  128.      This manual is still in *DRAFT* state.  Some sections are still
  129.      empty, or almost.  We keep merging material from other sources
  130.      (essentially e-mail folders) while the proper integration of this
  131.      material is delayed.
  132.    In this manual, we use *he* when speaking of the programmer or
  133. maintainer, *she* when speaking of the translator, and *they* when
  134. speaking of the installers or end users of the translated program.
  135. This is only a convenience for clarifying the documentation.  It is
  136. *absolutely* not meant to imply that some roles are more appropriate to
  137. males or females.  Besides, as you might guess, GNU `gettext' is meant
  138. to be useful for people using computers, whatever their sex, race,
  139. religion or nationality!
  140.    This chapter explains the goals sought in the creation of GNU
  141. `gettext'.  Then, it explains a few broad concepts around Native
  142. Language Support, and positions message translation with regard to
  143. other aspects of national and cultural variance, as they apply to to
  144. programs.  It also surveys those files used to convey the translations.
  145. It explains how the various tools interact in the initial generation
  146. of these files, and later, how the maintenance cycle should usually
  147. operate.
  148. * Menu:
  149. * Why::                         The Purpose of GNU `gettext'
  150. * Concepts::                    I18n, L10n, and Such
  151. * Aspects::                     Aspects in Native Language Support
  152. * Files::                       Files Conveying Translations
  153. * Overview::                    Overview of GNU `gettext'
  154. File: gettext.info,  Node: Why,  Next: Concepts,  Prev: Introduction,  Up: Introduction
  155. The Purpose of GNU `gettext'
  156. ============================
  157.    Usually, programs are written and documented in English, and use
  158. English at execution time to interact with users.  This is true not
  159. only of GNU software, but also of a great deal of commercial and free
  160. software.  Using a common language is quite handy for communication
  161. between developers, maintainers and users from all countries.  On the
  162. other hand, most people are less comfortable with English than with
  163. their own native language, and would prefer to use their mother tongue
  164. for day to day's work, as far as possible.  Many would simply *love* to
  165. see their computer screen showing a lot less of English, and far more
  166. of their own language.
  167.    However, to many people, this dream might appear so far fetched that
  168. they may believe it is not even worth spending time thinking about it.
  169. They have no confidence at all that the dream might ever become true.
  170. Yet some have not lost hope, and have organized themselves.  The GNU
  171. Translation Project is a formalization of this hope into a workable
  172. structure, which has a good chance to get all of us nearer the
  173. achievement of a truly multi-lingual set of programs.
  174.    GNU `gettext' is an important step for the GNU Translation Project,
  175. as it is an asset on which we may build many other steps.  This package
  176. offers to programmers, translators and even users, a well integrated
  177. set of tools and documentation.  Specifically, the GNU `gettext'
  178. utilities are a set of tools that provides a framework within which
  179. other GNU packages may produce multi-lingual messages.  These tools
  180. include a set of conventions about how programs should be written to
  181. support message catalogs, a directory and file naming organization for
  182. the message catalogs themselves, a runtime library supporting the
  183. retrieval of translated messages, and a few stand-alone programs to
  184. massage in various ways the sets of translatable strings, or already
  185. translated strings.  A special GNU Emacs mode also helps ease interested
  186. parties into preparing these sets, or bringing them up to date.
  187.    GNU `gettext' is designed to minimize the impact of
  188. internationalization on program sources, keeping this impact as small
  189. and hardly noticeable as possible.  Internationalization has better
  190. chances of succeeding if it is very light weighted, or at least, appear
  191. to be so, when looking at program sources.
  192.    The GNU Translation Project also uses the GNU `gettext' distribution
  193. as a vehicle for documenting its structure and methods.  This goes
  194. beyond the strict technicalities of documenting the GNU `gettext'
  195. proper.  By so doing, translators will find in a single place, as far
  196. as possible, all they need to know for properly doing their translating
  197. work.  Also, this supplemental documentation might also help
  198. programmers, and even curious users, in understanding how GNU `gettext'
  199. is related to the remainder of the GNU Translation Project, and
  200. consequently, have a glimpse at the *big picture*.
  201. File: gettext.info,  Node: Concepts,  Next: Aspects,  Prev: Why,  Up: Introduction
  202. I18n, L10n, and Such
  203. ====================
  204.    Two long words appear all the time when we discuss support of native
  205. language in programs, and these words have a precise meaning, worth
  206. being explained here, once and for all in this document.  The words are
  207. *internationalization* and *localization*.  Many people, tired of
  208. writing these long words over and over again, took the habit of writing
  209. "i18n" and "l10n" instead, quoting the first and last letter of each
  210. word, and replacing the run of intermediate letters by a number merely
  211. telling how many such letters there are.  But in this manual, in the
  212. sake of clarity, we will patiently write the names in full, each time...
  213.    By "internationalization", one refers to the operation by which a
  214. program, or a set of programs turned into a package, is made aware of
  215. and able to support multiple languages.  This is a generalization
  216. process, by which the programs are untied from calling only English
  217. strings or other English specific habits, and connected to generic ways
  218. of doing the same, instead.  Program developers may use various
  219. techniques to internationalize their programs.  Some of these have been
  220. standardized.  GNU `gettext' offers one of these standards.  *Note
  221. Programmers::.
  222.    By "localization", one means the operation by which, in a set of
  223. programs already internationalized, one gives the program all needed
  224. information so that it can adapt itself to handle its input and output
  225. in a fashion which is correct for some native language and cultural
  226. habits.  This is a particularisation process, by which generic methods
  227. already implemented in an internationalized program are used in
  228. specific ways.  The programming environment puts several functions to
  229. the programmers disposal which allow this runtime configuration.  The
  230. formal description of specific set of cultural habits for some country,
  231. together with all associated translations targeted to the same native
  232. language, is called the "locale" for this language or country.  Users
  233. achieve localization of programs by setting proper values to special
  234. environment variables, prior to executing those programs, identifying
  235. which locale should be used.
  236.    In fact, locale message support is only one component of the cultural
  237. data that makes up a particular locale.  There are a whole host of
  238. routines and functions provided to aid programmers in developing
  239. internationalized software and which allow them to access the data
  240. stored in a particular locale.  When someone presently refers to a
  241. particular locale, they are obviously referring to the data stored
  242. within that particular locale.  Similarly, if a programmer is referring
  243. to "accessing the locale routines", they are referring to the complete
  244. suite of routines that access all of the locale's information.
  245.    One uses the expression "Native Language Support", or merely NLS,
  246. for speaking of the overall activity or feature encompassing both
  247. internationalization and localization, allowing for multi-lingual
  248. interactions in a program.  In a nutshell, one could say that
  249. internationalization is the operation by which further localizations
  250. are made possible.
  251.    Also, very roughly said, when it comes to multi-lingual messages,
  252. internationalization is usually taken care of by programmers, and
  253. localization is usually taken care of by translators.
  254. File: gettext.info,  Node: Aspects,  Next: Files,  Prev: Concepts,  Up: Introduction
  255. Aspects in Native Language Support
  256. ==================================
  257.    For a totally multi-lingual distribution, there are many things to
  258. translate beyond output messages.
  259.    * As of today, GNU `gettext' offers a complete toolset for
  260.      translating messages output by C programs.  Perl scripts and shell
  261.      scripts will also need to be translated.  Even if there are today
  262.      some hooks by which this can be done, these hooks are not
  263.      integrated as well as they should be.
  264.    * Some programs, like `autoconf' or `bison', are able to produce
  265.      other programs (or scripts).  Even if the generating programs
  266.      themselves are internationalized, the generated programs they
  267.      produce may need internationalization on their own, and this
  268.      indirect internationalization could be automated right from the
  269.      generating program.  In fact, quite usually, generating and
  270.      generated programs could be internationalized independently, as
  271.      the effort needed is fairly orthogonal.
  272.    * A few programs include textual tables which might need translation
  273.      themselves, independently of the strings contained in the program
  274.      itself.  For example, RFC 1345 gives an English description for
  275.      each character which GNU `recode' is able to reconstruct at
  276.      execution.  Since these descriptions are extracted from the RFC by
  277.      mechanical means, translating them properly would require a prior
  278.      translation of the RFC itself.
  279.    * Almost all programs accept options, which are often worded out so
  280.      to be descriptive for the English readers; one might want to
  281.      consider offering translated versions for program options as well.
  282.    * Many programs read, interpret, compile, or are somewhat driven by
  283.      input files which are texts containing keywords, identifiers, or
  284.      replies which are inherently translatable.  For example, one may
  285.      want `gcc' to allow diacriticized characters in identifiers or use
  286.      translated keywords; `rm -i' might accept something else than `y'
  287.      or `n' for replies, etc.  Even if the program will eventually make
  288.      most of its output in the foreign languages, one has to decide
  289.      whether the input syntax, option values, etc., are to be localized
  290.      or not.
  291.    * The manual accompanying a package, as well as all documentation
  292.      files in the distribution, could surely be translated, too.
  293.      Translating a manual, with the intent of later keeping up with
  294.      updates, is a major undertaking in itself, generally.
  295.    As we already stressed, translation is only one aspect of locales.
  296. Other internationalization aspects are not currently handled by GNU
  297. `gettext', but perhaps may be handled in future versions.  There are
  298. many attributes that are needed to define a country's cultural
  299. conventions.  These attributes include beside the country's native
  300. language, the formatting of the date and time, the representation of
  301. numbers, the symbols for currency, etc.  These local "rules" are termed
  302. the country's locale.  The locale represents the knowledge needed to
  303. support the country's native attributes.
  304.    There are a few major areas which may vary between countries and
  305. hence, define what a locale must describe.  The following list helps
  306. putting multi-lingual messages into the proper context of other tasks
  307. related to locales, and also presents some other areas which GNU
  308. `gettext' might eventually tackle, maybe, one of these days.
  309. *Characters and Codesets*
  310.      The codeset most commonly used through out the USA and most English
  311.      speaking parts of the world is the ASCII codeset.  However, there
  312.      are many characters needed by various locales that are not found
  313.      within this codeset.  The 8-bit ISO 8859-1 code set has most of
  314.      the special characters needed to handle the major European
  315.      languages.  However, in many cases, the ISO 8859-1 font is not
  316.      adequate.  Hence each locale will need to specify which codeset
  317.      they need to use and will need to have the appropriate character
  318.      handling routines to cope with the codeset.
  319. *Currency*
  320.      The symbols used vary from country to country as does the position
  321.      used by the symbol.  Software needs to be able to transparently
  322.      display currency figures in the native mode for each locale.
  323. *Dates*
  324.      The format of date varies between locales.  For example, Christmas
  325.      day in 1994 is written as 12/25/94 in the USA and as 25/12/94 in
  326.      Australia.  Other countries might use ISO 8061 dates, etc.
  327.      Time of the day may be noted as HH:MM, HH.MM, or otherwise.  Some
  328.      locales require time to be specified in 24-hour mode rather than
  329.      as AM or PM.  Further, the nature and yearly extent of the
  330.      Daylight Saving correction vary widely between countries.
  331. *Numbers*
  332.      Numbers can be represented differently in different locales.  For
  333.      example, the following numbers are all written correctly for their
  334.      respective locales:
  335.           12,345.67       English
  336.           12.345,67       French
  337.           1,2345.67       Asia
  338.      Some programs could go further and use different unit systems, like
  339.      English units or Metric units, or even take into account variants
  340.      about how numbers are spelled in full.
  341. *Messages*
  342.      The most obvious area is the language support within a locale.
  343.      This is where GNU `gettext' provides the means for developers and
  344.      users to easily change the language that the software uses to
  345.      communicate to the user.
  346.    In the near future we see no chance that components of locale
  347. outside of message handling will be made available for use in other GNU
  348. packages.  The reason for this is that most modern systems provide a
  349. more or less reasonable support for at least some of the missing
  350. components.  Another point is that the GNU libc and Linux will get a
  351. new and complete implementation of the whole locale functionality which
  352. could be adopted by system lacking a reasonable locale support.
  353. File: gettext.info,  Node: Files,  Next: Overview,  Prev: Aspects,  Up: Introduction
  354. Files Conveying Translations
  355. ============================
  356.    The letters PO in `.po' files means Portable Object, to distinguish
  357. it from `.mo' files, where MO stands for Machine Object.  This
  358. paradigm, as well as the PO file format, is inspired by the NLS
  359. standard developed by Uniforum, and implemented by Sun in their Solaris
  360. system.
  361.    PO files are meant to be read and edited by humans, and associate
  362. each original, translatable string of a given package with its
  363. translation in a particular target language.  A single PO file is
  364. dedicated to a single target language.  If a package supports many
  365. languages, there is one such PO file per language supported, and each
  366. package has its own set of PO files.  These PO files are best created by
  367. the `xgettext' program, and later updated or refreshed through the
  368. `msgmerge' program.  Program `xgettext' extracts all marked messages
  369. from a set of C files and initializes a PO file with empty
  370. translations.  Program `msgmerge' takes care of adjusting PO files
  371. between releases of the corresponding sources, commenting obsolete
  372. entries, initializing new ones, and updating all source line
  373. references.  Files ending with `.pot' are kind of base translation
  374. files found in distributions, in PO file format, and `.pox' files are
  375. often temporary PO files.
  376.    MO files are meant to be read by programs, and are binary in nature.
  377. A few systems already offer tools for creating and handling MO files as
  378. part of the Native Language Support coming with the system, but the
  379. format of these MO files is often different from system to system, and
  380. non-portable.  They do not necessary use `.mo' for file extensions, but
  381. since system libraries are also used for accessing these files, it
  382. works as long as the system is self-consistent about it.  If GNU
  383. `gettext' is able to interface with the tools already provided with
  384. systems, it will consequently let these provided tools take care of
  385. generating the MO files.  Or else, if such tools are not found or do
  386. not seem usable, GNU `gettext' will use its own ways and its own format
  387. for MO files.  Files ending with `.gmo' are really MO files, when it is
  388. known that these files use the GNU format.
  389. File: gettext.info,  Node: Overview,  Prev: Files,  Up: Introduction
  390. Overview of GNU `gettext'
  391. =========================
  392.    The following diagram summarizes the relation between the files
  393. handled by GNU `gettext' and the tools acting on these files.  It is
  394. followed by a somewhat detailed explanations, which you should read
  395. while keeping an eye on the diagram.  Having a clear understanding of
  396. these interrelations would surely help programmers, translators and
  397. maintainers.
  398.      Original C Sources ---> PO mode ---> Marked C Sources ---.
  399.                                                               |
  400.                    .---------<--- GNU gettext Library         |
  401.      .--- make <---+                                          |
  402.      |             `---------<--------------------+-----------'
  403.      |                                            |
  404.      |   .-----<--- PACKAGE.pot <--- xgettext <---'   .---<--- PO Compendium
  405.      |   |                                            |             ^
  406.      |   |                                            `---.         |
  407.      |   `---.                                            +---> PO mode ---.
  408.      |       +----> msgmerge ------> LANG.pox --->--------'                |
  409.      |   .---'                                                             |
  410.      |   |                                                                 |
  411.      |   `-------------<---------------.                                   |
  412.      |                                 +--- LANG.po <--- New LANG.pox <----'
  413.      |   .--- LANG.gmo <--- msgfmt <---'
  414.      |   |
  415.      |   `---> install ---> /.../LANG/PACKAGE.mo ---.
  416.      |                                              +---> "Hello world!"
  417.      `-------> install ---> /.../bin/PROGRAM -------'
  418.    The indication `PO mode' appears in two places in this picture, and
  419. you may safely read it as merely meaning "hand editing", using any
  420. editor of your choice, really.  However, for those of you being the
  421. lucky users of GNU Emacs, PO mode has been specifically created for
  422. providing a cozy environment for editing or modifying PO files.  While
  423. editing a PO file, PO mode allows for the easy browsing of auxiliary
  424. and compendium PO files, as well as for following references into the
  425. set of C program sources from which PO files have been derived.  It has
  426. a few special features, among which are the interactive marking of
  427. program strings as translatable, and the validatation of PO files with
  428. easy repositioning to PO file lines showing errors.
  429.    As a programmer, the first step to bringing GNU `gettext' into your
  430. package is identifying, right in the C sources, those strings which are
  431. meant to be translatable, and those which are untranslatable.  This
  432. tedious job can be done a little more comfortably using emacs PO mode,
  433. but you can use any means familiar to you for modifying your C sources.
  434. Beside this some other simple, standard changes are needed to properly
  435. initialize the translation library.  *Note Sources::, for more
  436. information about all this.
  437.    For newly written software the strings of course can and should be
  438. marked while writing the it.  The `gettext' approach makes this very
  439. easy.  Simply put the following lines at the beginning of each file or
  440. in a central header file:
  441.      #define _(String) (String)
  442.      #define N_(String) (String)
  443.      #define textdomain(Domain)
  444.      #define bindtextdomain(Package, Directory)
  445. Doing this allows you to prepare the sources for internationalization.
  446. Later when you feel ready for the step to use the `gettext' library
  447. simply remove these definitions, include `libintl.h' and link against
  448. `libintl.a'.  That is all you have to change.
  449.    Once the C sources have been modified, the `xgettext' program is
  450. used to find and extract all translatable strings, and create an
  451. initial PO file out of all these.  This `PACKAGE.pot' file contains all
  452. original program strings.  It has sets of pointers to exactly where in
  453. C sources each string is used.  All translations are set to empty.  The
  454. letter `t' in `.pot' marks this as a Template PO file, not yet oriented
  455. towards any particular language.  *Note xgettext Invocation::, for more
  456. details about how one calls the `xgettext' program.  If you are
  457. *really* lazy, you might be interested at working a lot more right
  458. away, and preparing the whole distribution setup (*note
  459. Maintainers::.).  By doing so, you spare yourself typing the `xgettext'
  460. command, as `make' should now generate the proper things automatically
  461. for you!
  462.    The first time through, there is no `LANG.po' yet, so the `msgmerge'
  463. step may be skipped and replaced by a mere copy of `PACKAGE.pot' to
  464. `LANG.pox', where LANG represents the target language.
  465.    Then comes the initial translation of messages.  Translation in
  466. itself is a whole matter, still exclusively meant for humans, and whose
  467. complexity far overwhelms the level of this manual.  Nevertheless, a
  468. few hints are given in some other chapter of this manual (*note
  469. Translators::.).  You will also find there indications about how to
  470. contact translating teams, or becoming part of them, for sharing your
  471. translating concerns with others who target the same native language.
  472.    While adding the translated messages into the `LANG.pox' PO file, if
  473. you do not have GNU Emacs handy, you are on your own for ensuring that
  474. your efforts fully respect the PO file format, and quoting conventions
  475. (*note PO Files::.).  This is surely not an impossible task, as this is
  476. the way many people have handled PO files already for Uniforum or
  477. Solaris.  On the other hand, by using PO mode in GNU Emacs, most details
  478. of PO file format are taken care of for you, but you have to acquire
  479. some familiarity with PO mode itself.  Besides main PO mode commands
  480. (*note Main PO Commands::.), you should know how to move between entries
  481. (*note Entry Positioning::.), and how to handle untranslated entries
  482. (*note Untranslated Entries::.).
  483.    If some common translations have already been saved into a compendium
  484. PO file, translators may use PO mode for initializing untranslated
  485. entries from the compendium, and also save selected translations into
  486. the compendium, updating it (*note Compendium::.).  Compendium files
  487. are meant to be exchanged between members of a given translation team.
  488.    Programs, or packages of programs, are dynamic in nature: users write
  489. bug reports and suggestion for improvements, maintainers react by
  490. modifying programs in various ways.  The fact that a package has
  491. already been internationalized should not make maintainers shy of
  492. adding new strings, or modifying strings already translated.  They just
  493. do their job the best they can.  For the GNU Translation Project to
  494. work smoothly, it is important that maintainers do not carry
  495. translation concerns on their already loaded shoulders, and that
  496. translators be kept as free as possible of programmatic concerns.
  497.    The only concern maintainers should have is carefully marking new
  498. strings as translatable, when they should be, and do not otherwise
  499. worry about them being translated, as this will come in proper time.
  500. Consequently, when programs and their strings are adjusted in various
  501. ways by maintainers, and for matters usually unrelated to translation,
  502. `xgettext' would construct `PACKAGE.pot' files which are evolving over
  503. time, so the translations carried by `LANG.po' are slowly fading out of
  504. date.
  505.    It is important for translators (and even maintainers) to understand
  506. that package translation is a continuous process in the lifetime of a
  507. package, and not something which is done once and for all at the start.
  508. After an initial burst of translation activity for a given package,
  509. interventions are needed once in a while, because here and there,
  510. translated entries become obsolete, and new untranslated entries
  511. appear, needing translation.
  512.    The `msgmerge' program has the purpose of refreshing an already
  513. existing `LANG.po' file, by comparing it with a newer `PACKAGE.pot'
  514. template file, extracted by `xgettext' out of recent C sources.  The
  515. refreshing operation adjusts all references to C source locations for
  516. strings, since these strings move as programs are modified.  Also,
  517. `msgmerge' comments out as obsolete, in `LANG.pox', those already
  518. translated entries which are no longer used in the program sources
  519. (*note Obsolete Entries::..  It finally discovers new strings and
  520. inserts them in the resulting PO file as untranslated entries (*note
  521. Untranslated Entries::..  *Note msgmerge Invocation::, for more
  522. information about what `msgmerge' really does.
  523.    Whatever route or means taken, the goal is to obtain an updated
  524. `LANG.pox' file offering translations for all strings.  When this is
  525. properly achieved, this file `LANG.pox' may take the place of the
  526. previous official `LANG.po' file.
  527.    The temporal mobility, or fluidity of PO files, is an integral part
  528. of the translation game, and should be well understood, and accepted.
  529. People resisting it will have a hard time participating in the GNU
  530. Translation Project, or will give a hard time to other participants!  In
  531. particular, maintainers should relax and include all available official
  532. PO files in their distributions, even if these have not recently been
  533. updated, without banging or otherwise trying to exert pressure on the
  534. translator teams to get the job done.  The pressure should rather come
  535. from the community of users speaking a particular language, and
  536. maintainers should consider themselves fairly relieved of any concern
  537. about the adequacy of translation files.  On the other hand, translators
  538. should reasonably try updating the PO files they are responsible for,
  539. while the package is undergoing pretest, prior to an official
  540. distribution.
  541.    Once the PO file is complete and dependable, the `msgfmt' program is
  542. used for turning the PO file into a machine-oriented format, which may
  543. yield efficient retrieval of translations by the programs of the
  544. package, whenever needed at runtime (*note MO Files::.).  *Note msgfmt
  545. Invocation::, for more information about all modalities of execution
  546. for the `msgfmt' program.
  547.    Finally, the modified and marked C sources are compiled and linked
  548. with the GNU `gettext' library, usually through the operation of
  549. `make', given a suitable `Makefile' exists for the project, and the
  550. resulting executable is installed somewhere users will find it.  The MO
  551. files themselves should also be properly installed.  Given the
  552. appropriate environment variables are set (*note End Users::.), the
  553. program should localize itself automatically, whenever it executes.
  554.    The remainder of this manual has the purpose of explaining in depth
  555. the various steps outlined above.
  556. File: gettext.info,  Node: Basics,  Next: Sources,  Prev: Introduction,  Up: Top
  557. PO Files and PO Mode Basics
  558. ***************************
  559.    The GNU `gettext' toolset helps programmers and translators at
  560. producing, updating and using translation files, mainly those PO files
  561. which are textual, editable files.  This chapter stresses the format of
  562. PO files, and contains a PO mode starter.  PO mode description is
  563. spread throughout this manual instead of being concentrated in one
  564. place.  Here we present only the basics of PO mode.
  565. * Menu:
  566. * Installation::                Completing GNU `gettext' Installation
  567. * PO Files::                    The Format of PO Files
  568. * Main PO Commands::            Main Commands
  569. * Entry Positioning::           Entry Positioning
  570. * Normalizing::                 Normalizing Strings in Entries
  571. File: gettext.info,  Node: Installation,  Next: PO Files,  Prev: Basics,  Up: Basics
  572. Completing GNU `gettext' Installation
  573. =====================================
  574.    Once you have received, unpacked, configured and compiled the GNU
  575. `gettext' distribution, the `make install' command puts in place the
  576. programs `xgettext', `msgfmt', `gettext', and `msgmerge', as well as
  577. their available message catalogs.  To top off a comfortable
  578. installation, you might also want to make the PO mode available to your
  579. GNU Emacs users.
  580.    During the installation of the PO mode, you might want modify your
  581. file `.emacs', once and for all, so it contains a few lines looking
  582. like:
  583.      (setq auto-mode-alist
  584.            (cons '("\\.po[tx]?\\'\\|\\.po\\." . po-mode) auto-mode-alist))
  585.      (autoload 'po-mode "po-mode")
  586.    Later, whenever you edit some `.po', `.pot' or `.pox' file, or any
  587. file having the string `.po.' within its name, Emacs loads
  588. `po-mode.elc' (or `po-mode.el') as needed, and automatically activates
  589. PO mode commands for the associated buffer.  The string *PO* appears in
  590. the mode line for any buffer for which PO mode is active.  Many PO
  591. files may be active at once in a single Emacs session.
  592. File: gettext.info,  Node: PO Files,  Next: Main PO Commands,  Prev: Installation,  Up: Basics
  593. The Format of PO Files
  594. ======================
  595.    A PO file is made up of many entries, each entry holding the relation
  596. between an original untranslated string and its corresponding
  597. translation.  All entries in a given PO file usually pertain to a
  598. single project, and all translations are expressed in a single target
  599. language.  One PO file "entry" has the following schematic structure:
  600.      WHITE-SPACE
  601.      #  TRANSLATOR-COMMENTS
  602.      #. AUTOMATIC-COMMENTS
  603.      #: REFERENCE...
  604.      #, FLAG...
  605.      msgid UNTRANSLATED-STRING
  606.      msgstr TRANSLATED-STRING
  607.    The general structure of a PO file should be well understood by the
  608. translator.  When using PO mode, very little has to be known about the
  609. format details, as PO mode takes care of them for her.
  610.    Entries begin with some optional white space.  Usually, when
  611. generated through GNU `gettext' tools, there is exactly one blank line
  612. between entries.  Then comments follow, on lines all starting with the
  613. character `#'.  There are two kinds of comments: those which have some
  614. white space immediately following the `#', which comments are created
  615. and maintained exclusively by the translator, and those which have some
  616. non-white character just after the `#', which comments are created and
  617. maintained automatically by GNU `gettext' tools.  All comments, of
  618. either kind, are optional.
  619.    After white space and comments, entries show two strings, giving
  620. first the untranslated string as it appears in the original program
  621. sources, and then, the translation of this string.  The original string
  622. is introduced by the keyword `msgid', and the translation, by `msgstr'.
  623. The two strings, untranslated and translated, are quoted in various
  624. ways in the PO file, using `"' delimiters and `\' escapes, but the
  625. translator does not really have to pay attention to the precise quoting
  626. format, as PO mode fully intend to take care of quoting for her.
  627.    The `msgid' strings, as well as automatic comments, are produced and
  628. managed by other GNU `gettext' tools, and PO mode does not provide
  629. means for the translator to alter these.  The most she can do is merely
  630. deleting them, and only by deleting the whole entry.  On the other
  631. hand, the `msgstr' string, as well as translator comments, are really
  632. meant for the translator, and PO mode gives her the full control she
  633. needs.
  634.    The comment lines beginning with `#,' are special because they are
  635. not completely ignored by the programs as comments generally are.  The
  636. comma separated list of FLAGs is used by the `msgfmt' program to give
  637. the user some better disgnostic messages.  Currently there are two
  638. forms of flags defined:
  639. `fuzzy'
  640.      This flag can be generated by the `msgmerge' program or it can be
  641.      inserted by the translator herself.  It shows that the `msgstr'
  642.      string might not be a correct translation (anymore).  Only the
  643.      translator can judge if the translation requires further
  644.      modification, or is acceptable as is.  Once satisfied with the
  645.      translation, she then removes this `fuzzy' attribute.  The
  646.      `msgmerge' programs inserts this when it combined the `msgid' and
  647.      `msgstr' entries after fuzzy search only.  *Note Fuzzy Entries::.
  648. `c-format'
  649. `no-c-format'
  650.      These flags should not be added by a human.  Instead only the
  651.      `xgettext' program adds them.  In an automatized PO file processing
  652.      system as proposed here the user changes would be thrown away
  653.      again as soon as the `xgettext' program generates a new template
  654.      file.
  655.      In case the `c-format' flag is given for a string the `msgfmt'
  656.      does some more tests to check to validity of the translation.
  657.      *Note msgfmt Invocation::.
  658.    It happens that some lines, usually whitespace or comments, follow
  659. the very last entry of a PO file.  Such lines are not part of any entry,
  660. and PO mode is unable to take action on those lines.  By using the PO
  661. mode function `M-x po-normalize', the translator may get rid of those
  662. spurious lines.  *Note Normalizing::.
  663.    The remainder of this section may be safely skipped by those using
  664. PO mode, yet it may be interesting for everybody to have a better idea
  665. of the precise format of a PO file.  On the other hand, those not
  666. having GNU Emacs handy should carefully continue reading on.
  667.    Each of UNTRANSLATED-STRING and TRANSLATED-STRING respects the C
  668. syntax for a character string, including the surrounding quotes and
  669. imbedded backslashed escape sequences.  When the time comes to write
  670. multi-line strings, one should not use escaped newlines.  Instead, a
  671. closing quote should follow the last character on the line to be
  672. continued, and an opening quote should resume the string at the
  673. beginning of the following PO file line.  For example:
  674.      msgid ""
  675.      "Here is an example of how one might continue a very long string\n"
  676.      "for the common case the string represents multi-line output.\n"
  677. In this example, the empty string is used on the first line, to allow
  678. better alignment of the `H' from the word `Here' over the `f' from the
  679. word `for'.  In this example, the `msgid' keyword is followed by three
  680. strings, which are meant to be concatenated.  Concatenating the empty
  681. string does not change the resulting overall string, but it is a way
  682. for us to comply with the necessity of `msgid' to be followed by a
  683. string on the same line, while keeping the multi-line presentation
  684. left-justified, as we find this to be a cleaner disposition.  The empty
  685. string could have been omitted, but only if the string starting with
  686. `Here' was promoted on the first line, right after `msgid'.(1) It was
  687. not really necessary either to switch between the two last quoted
  688. strings immediately after the newline `\n', the switch could have
  689. occurred after *any* other character, we just did it this way because
  690. it is neater.
  691.    One should carefully distinguish between end of lines marked as `\n'
  692. *inside* quotes, which are part of the represented string, and end of
  693. lines in the PO file itself, outside string quotes, which have no
  694. incidence on the represented string.
  695.    Outside strings, white lines and comments may be used freely.
  696. Comments start at the beginning of a line with `#' and extend until the
  697. end of the PO file line.  Comments written by translators should have
  698. the initial `#' immediately followed by some white space.  If the `#'
  699. is not immediately followed by white space, this comment is most likely
  700. generated and managed by specialized GNU tools, and might disappear or
  701. be replaced unexpectedly when the PO file is given to `msgmerge'.
  702.    ---------- Footnotes ----------
  703.    (1)  This limitation is not imposed by GNU `gettext', but comes from
  704. the `msgfmt' implementation on Solaris.
  705. File: gettext.info,  Node: Main PO Commands,  Next: Entry Positioning,  Prev: PO Files,  Up: Basics
  706. Main PO mode Commands
  707. =====================
  708.    After setting up Emacs with something similar to the lines in *Note
  709. Installation::, PO mode is activated for a window when Emacs finds a PO
  710. file in that window.  This puts the window read-only and establishes a
  711. po-mode-map, which is a genuine Emacs mode, in a way that is not
  712. derived from text mode in any way.
  713.    The main PO commands are those which do not fit into the other
  714. categories of subsequent sections.  These allow for quitting PO mode or
  715. for managing windows in special ways.
  716.      Undo last modification to the PO file.
  717.      Quit processing and save the PO file.
  718.      Temporary leave the PO file window.
  719.      Show help about PO mode.
  720.      Give some PO file statistics.
  721.      Batch validate the format of the whole PO file.
  722.    The command `U' (`po-undo') interfaces to the GNU Emacs *undo*
  723. facility.  *Note Undoing Changes: (emacs)Undo.  Each time `U' is typed,
  724. modifications which the translator did to the PO file are undone a
  725. little more.  For the purpose of undoing, each PO mode command is
  726. atomic.  This is especially true for the `RET' command: the whole
  727. edition made by using a single use of this command is undone at once,
  728. even if the edition itself implied several actions.  However, while in
  729. the editing window, one can undo the edition work quite parsimoniously.
  730.    The command `Q' (`po-quit') is used when the translator is done with
  731. the PO file.  If the file has been modified, it is saved to disk first.
  732. However, prior to all this, the command checks if some untranslated
  733. message remains in the PO file and, if yes, the translator is asked if
  734. she really wants to leave off working with this PO file.  This is the
  735. preferred way of getting rid of an Emacs PO file buffer.  Merely
  736. killing it through the usual command `C-x k' (`kill-buffer'), say, has
  737. the untidy effect of leaving a PO internal work buffer behind.
  738.    The command `O' (`po-other-window') is another, softer way, to leave
  739. PO mode, temporarily.  It just moves the cursor to some other Emacs
  740. window, and pops one if necessary.  For example, if the translator just
  741. got PO mode to show some source context in some other, she might
  742. discover some apparent bug in the program source that needs correction.
  743. This command allows the translator to change sex, become a programmer,
  744. and have the cursor right into the window containing the program she
  745. (or rather *he*) wants to modify.  By later getting the cursor back in
  746. the PO file window, or by asking Emacs to edit this file once again, PO
  747. mode is then recovered.
  748.    The command `h' (`po-help') displays a summary of all available PO
  749. mode commands.  The translator should then type any character to resume
  750. normal PO mode operations.  The command `?' has the same effect as `h'.
  751.    The command `=' (`po-statistics') computes the total number of
  752. entries in the PO file, the ordinal of the current entry (counted from
  753. 1), the number of untranslated entries, the number of obsolete entries,
  754. and displays all these numbers.
  755.    The command `V' (`po-validate') launches `msgfmt' in verbose mode
  756. over the current PO file.  This command first offers to save the
  757. current PO file on disk.  The `msgfmt' tool, from GNU `gettext', has
  758. the purpose of creating a MO file out of a PO file, and PO mode uses
  759. the features of this program for checking the overall format of a PO
  760. file, as well as all individual entries.
  761.    The program `msgfmt' runs asynchronously with Emacs, so the
  762. translator regains control immediately while her PO file is being
  763. studied.  Error output is collected in the GNU Emacs `*compilation*'
  764. buffer, displayed in another window.  The regular GNU Emacs command
  765. `C-x`' (`next-error'), as well as other usual compile commands, allow
  766. the translator to reposition quickly to the offending parts of the PO
  767. file.  Once the cursor is on the line in error, the translator may
  768. decide on any PO mode action which would help correcting the error.
  769.