TIP 404: Let Message Catalogs get the Locale from their File Name

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Harald Oehlmann <harald.oehlmann@elmicron.de>
State:          Final
Type:           Project
Vote:           Done
Created:        17-Jul-2011
Post-History:   
Discussions-To: Tcl Core list
Keywords:       msgcat, convention
Tcl-Version:    8.6

Abstract

This TIP proposes a mechanism for coupling locales more strongly to the names of the files that define them, an already-recommended practice, so as to make it less error-prone to produce message catalogs.

Rationale

Current message catalog files are as follows:

Example with equal "de":

-de.msg-
::msgcat::mcset de Open Öffnen
::msgcat::mcset de Close Schliessen
-eof-

The same locale value (de) is contained in the file name and in each mcset command.

This is technically unnecessary and error-prone. I found myself often copying message file contents from one language to the next and not setting the right locale in each mcset command.

The scope of this TIP is a new command similar to mcset which determines the locale from the file name.

IMHO it makes no sense to specify the locale of mcset commands and the locale in the file name different and thus separately.

Specification

mc file locale

The mc file locale is a locale specified by the file name of a message file.

Example:

Message catalogue file name: de_ch.msg

mc file locale: de_ch

The package msgcat maintains one value, mc file locale, with the following properties:

The command ::msgcat::mcconfig is shared with [399]. It has a new option -mcfilelocale.

New Commands

There are two new commands:

These work as:

   ::msgcat::mcset [::msgcat::mcconfig -mcfilelocale] source ?translation?
   ::msgcat::mcmset [::msgcat::mcconfig -mcfilelocale] list

The command name mcflset is an abreviation of: "message c'atalogue with **file locale set".

Example Usages

The example of the Rationale section above may now be written as:

-de.msg-
::msgcat::mcflset Open Öffnen
::msgcat::mcflset Close Schliessen
-eof-

The locale value de only appears in the file name.

Further examples are in the tcl wiki msgcat page: http://wiki.tcl.tk/msgcat

Reference Implementation

See Tcl Feature Request 3544988. http://sourceforge.net/support/tracker.php/?aid=3544988

Copyright

This document has been placed in the public domain.

History