diff options
author | dgp <dgp@users.sourceforge.net> | 2007-10-26 20:11:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-10-26 20:11:50 (GMT) |
commit | 6b9dd216db20bac6c76552a6193d67a01e1d34ee (patch) | |
tree | b86166558de62f70eef1a7524fac75f7b47a4f44 /doc/msgcat.n | |
parent | 236c395276f8f1cf4d5b745ea490b4966e6eb148 (diff) | |
download | tcl-6b9dd216db20bac6c76552a6193d67a01e1d34ee.zip tcl-6b9dd216db20bac6c76552a6193d67a01e1d34ee.tar.gz tcl-6b9dd216db20bac6c76552a6193d67a01e1d34ee.tar.bz2 |
* changes: Updated for 8.5b2 release.core_8_5_b2
* doc/*.1: Revert doc changes that broke
* doc/*.3: `make html` so we can get the release
* doc/*.n: out the door.
Diffstat (limited to 'doc/msgcat.n')
-rw-r--r-- | doc/msgcat.n | 83 |
1 files changed, 27 insertions, 56 deletions
diff --git a/doc/msgcat.n b/doc/msgcat.n index aaa8b4f..7bff211 100644 --- a/doc/msgcat.n +++ b/doc/msgcat.n @@ -33,13 +33,13 @@ msgcat \- Tcl message catalog .sp \fB::msgcat::mcunknown \fIlocale src-string\fR .BE + .SH DESCRIPTION .PP The \fBmsgcat\fR package provides a set of functions that can be used to manage multi-lingual user interfaces. -Text strings are defined in a -.QW "message catalog" -which is independent from the application, and +Text strings are defined in a ``message catalog'' which +is independent from the application, and which can be edited or localized without modifying the application source code. New languages or locales are provided by adding a new file to @@ -94,16 +94,14 @@ locale set in msgcat by \fB::msgcat::mclocale\fR, and cannot be set independently. For example, if the current locale is en_US_funky, then \fB::msgcat::mcpreferences\fR .VS 1.4 -returns -.QW "\fBen_US_funky en_US en {}\fR" . +returns \fB{en_US_funky en_US en {}}\fR. .VE 1.4 .TP \fB::msgcat::mcload \fIdirname\fR Searches the specified directory for files that match the language specifications returned by \fB::msgcat::mcpreferences\fR -(note that these are all lowercase), extended by the file extension -.QW .msg . -Each matching file is +(note that these are all lowercase), extended by the file +extension ``.msg''. Each matching file is read in order, assuming a UTF-8 encoding. The file contents are then evaluated as a Tcl script. This means that Unicode characters may be present in the message file either directly in their UTF-8 @@ -122,9 +120,8 @@ Sets the translation for multiple source strings in \fIsrc-trans-list\fR in the specified \fIlocale\fR and the current namespace. \fIsrc-trans-list\fR must have an even number of elements and is in -the form -.QW "\fIsrc-string translate-string\fR ?\fIsrc-string translate-string ...\fR?}" . -The \fB::msgcat::mcmset\fR command can be significantly +the form {\fIsrc-string translate-string\fR ?\fIsrc-string +translate-string ...\fR?} \fB::msgcat::mcmset\fR can be significantly faster than multiple invocations of \fB::msgcat::mcset\fR. The function returns the number of translations set. .TP @@ -144,15 +141,10 @@ The locale is specified to \fBmsgcat\fR by a locale string passed to \fB::msgcat::mclocale\fR. The locale string consists of a language code, an optional country code, and an optional -system-specific code, each separated by -.QW _ . -The country and language +system-specific code, each separated by ``_''. The country and language codes are specified in standards ISO-639 and ISO-3166. -For example, the locale -.QW en -specifies English and -.QW en_US -specifies U.S. English. +For example, the locale ``en'' specifies English and ``en_US'' specifies +U.S. English. .PP When the msgcat package is first loaded, the locale is initialized according to the user's environment. The variables \fBenv(LC_ALL)\fR, @@ -171,20 +163,12 @@ On Windows, if none of those environment variables is set, msgcat will attempt to extract locale information from the registry. If all these attempts to discover an initial locale from the user's environment fail, msgcat defaults to an initial -locale of -.QW C . +locale of ``C''. .PP -When a locale is specified by the user, a -.QW "best match" -search is +When a locale is specified by the user, a ``best match'' search is performed during string translation. For example, if a user specifies .VS 1.4 -en_GB_Funky, the locales -.QW en_GB_Funky , -.QW en_GB , -.QW en -and -.MT +en_GB_Funky, the locales ``en_GB_Funky'', ``en_GB'', ``en'' and ``'' (the empty string) .VE 1.4 are searched in order until a matching translation @@ -217,13 +201,10 @@ hello from ::foo When searching for a translation of a message, the message catalog will search first the current namespace, then the parent of the current namespace, and so on until -the global namespace is reached. This allows child namespaces to -.QW inherit -messages from their parent namespace. +the global namespace is reached. This allows child namespaces +to "inherit" messages from their parent namespace. .PP -For example, executing (in the -.QW en -locale) the code +For example, executing (in the ``en'' locale) the code .CS \fB::msgcat::mcset\fR en m1 ":: message1" \fB::msgcat::mcset\fR en m2 ":: message2" @@ -254,36 +235,28 @@ to the following conditions: All message files for a package are in the same directory. .IP [2] The message file name is a msgcat locale specifier (all lowercase) -followed by -.QW .msg . -For example: -.RS +followed by ``.msg''. For example: .CS es.msg -- spanish en_gb.msg -- United Kingdom English .CE .VS 1.4 -\fIException:\fR The message file for the root locale -.MT -is called \fBROOT.msg\fR. This exception is made so as not to +\fIException:\fR The message file for the root locale ``'' is +called \fBROOT.msg\fR. This exception is made so as not to cause peculiar behavior, such as marking the message file as -.QW hidden -on Unix file systems. +``hidden'' on Unix file systems. .VE 1.4 -.RE .IP [3] The file contains a series of calls to \fBmcset\fR and \fBmcmset\fR, setting the necessary translation strings for the language, likely enclosed in a \fBnamespace eval\fR so that all source strings are tied to the namespace of the package. For example, a short \fBes.msg\fR might contain: -.RS .CS namespace eval ::mypackage { \fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!" } .CE -.RE .SH "RECOMMENDED MESSAGE SETUP FOR PACKAGES" .PP If a package is installed into a subdirectory of the @@ -295,13 +268,12 @@ During package installation, create a subdirectory .IP [2] Copy your *.msg files into that directory. .IP [3] -Add the following command to your package initialization script: -.RS + Add the following command to your package +initialization script: .CS # load language files, stored in msgs subdirectory \fB::msgcat::mcload\fR [file join [file dirname [info script]] msgs] .CE -.RE .SH "POSITIONAL CODES FOR FORMAT AND SCAN COMMANDS" .PP It is possible that a message string used as an argument @@ -314,7 +286,8 @@ format "We produced %d units in location %s" $num $city format "In location %s we produced %d units" $city $num .CE .PP -This can be handled by using the positional parameters: +This can be handled by using the positional +parameters: .CS format "We produced %1\\$d units in location %2\\$s" $num $city format "In location %2\\$s we produced %1\\$d units" $num $city @@ -322,14 +295,12 @@ format "In location %2\\$s we produced %1\\$d units" $num $city .PP Similarly, positional parameters can be used with \fBscan\fR to extract values from internationalized strings. -.PP -\fINote:\fR for the specific case of formatting a string, you should -take advantage of the fact that the \fB::msgcat::mc\fR command already -passes its string through \fBformat\fR internally. .SH CREDITS .PP The message catalog code was developed by Mark Harrison. + .SH "SEE ALSO" format(n), scan(n), namespace(n), package(n) + .SH KEYWORDS internationalization, i18n, localization, l10n, message, text, translation |