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