Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > TIP #156: Language-Neutral Root Locale for Msgcat
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 5th November 20:35
kevin kenny
External User
 
Posts: 1
Default TIP #156: Language-Neutral Root Locale for Msgcat



TIP #156: LANGUAGE-NEUTRAL ROOT LOCALE FOR MSGCAT
================================================== =
Version: $Revision: 1.1 $
Author: Kevin Kenny <kennykb_at_acm.org>
State: Draft
Type: Project
Tcl-Version: 8.5
Vote: Pending
Created: Saturday, 20 September 2003
URL: http://purl.org/tcl/tip/156.html
WebEdit: http://purl.org/tcl/tip/edit/156
Discussions-To: news:comp.lang.tcl
Post-History:

-------------------------------------------------------------------------

ABSTRACT
==========

This TIP proposes to extend Tcl's message catalog mechanism by adding a
"root locale" (whose name is the empty string) that is searched after
searches in all the language-dependent locales have failed.

RATIONALE
===========

In the current message catalog system, the search key for localized
strings is a version of the string itself, expressed in either a
language-neutral form or in the natural language of the programmer.
This scheme has the advantage that when a program searches for a
localized message, the search will always succeed; if a translation of
the message cannot be found in any of the message catalog preferences,
at least a language-neutral string (or a string in an inappropriate
language) will be available.

The drawback to the scheme as it stands comes when ambiguities enter
into the picture. For instance, the English word, 'file,' might,
depending on context, appear in French as the word 'fichier,' or the
word, 'rāpe.' An application implementing a catalog of hand tools might
well encounter such an ambiguity.

A more specific example that I have encountered deals with date and
time formatting. Consider the [clock format] command. It accepts a
format group, %x, that formats the current date in the default format
for the current locale. It also accepts a group, %D, that formats the
current date in the specific format %m/%d/%Y. In both the 'C' locale
and the 'en_US' locale, these two format groups generate identical
strings. If the message catalog is used to store them, there has to be
a way to have distinct keys look up the same string in the
language-neutral default locale.

SPECIFICATION
===============

The solution that both Java and ICU use for managing the problem of
ambiguity in the default locale is to implement a "root locale" that is
searched after the searches in the current language-dependent locales
have failed. If a translation is found in the "root locale", it is used
just as if it was found in a language-dependent locale.

This TIP proposes the same for Tcl. Specifically, it proposes that.

1. The _msgcat::mcpreferences_ command will be modified to add the
empty string as a list element after the elements corresponding
to the current locale. If the current locale, for instance, is
_en_US_funky_, the result of [mcpreferences] will be
_{en_US_funky en_US en {}}_, and if the current locale is
_de_CH_schwyzertuetsch_, the four locales to be searched will be:

* _de_CH_schwyzertuetsch_

* _de_CH_

* _de_

* {} (the empty locale)

2. The _msgcat::mcload_ command will be modified so that if it
encounters the empty string as a locale name, it will replace it
with ROOT. This modification is made so that the empty locale
will correspond to a file named, "ROOT.msg" rather than just
".msg", and hence yield a file whose name does not begin with a
period. Files whose names begin with periods are treated
specially on certain filesystems (for instance, on Unix, they
become files hidden from the _ls_ command), and avoiding such
names seems wise. The implementors of both Java and ICU have made
the same decision.

REFERENCE IMPLEMENTATION
==========================

The changes require to implement this proposal are minimal and can be
obtained from SourceForge as Tcl Patch #809825.

COPYRIGHT
===========

Copyright © 2003 by Kevin B. Kenny. All rights reserved.

Permission to use this do***ent in accordance with the terms of Open
Publication License (<URL:http://www.opencontent.org/openpub/>) is
herewith granted.

-------------------------------------------------------------------------

[[Send Tcl/Tk announcements to tcl-announce@mitchell.org
Announcements archived at http://groups.yahoo.com/group/tcl_announce/
Send administrivia to tcl-announce-request@mitchell.org
Tcl/Tk at http://tcl.tk/ ]]
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666