Let Message Catalogs get the Locale from their File NameHarald Oehlmann$Revision: 1.9 $msgcat convention
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.
Current message catalog files are as follows:
Catalog file name: <locale> .msgCatalog folder: technically any, recommended: msgs in package main folder. Must be specified to the command mcload.Catalog file contents: one command per translated item:ICAgICAgICBtc2djYXQ6Om1jc2V0IGxvY2FsZSBvcmkgP3RyYW5zbGF0aW9uPw==
Example with <locale> equal "de":
LWRlLm1zZy0=Ojptc2djYXQ6Om1jc2V0IGRlIE9wZW4g1mZmbmVuOjptc2djYXQ6Om1jc2V0IGRlIENsb3NlIFNjaGxpZXNzZW4=LWVvZi0=
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.
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:
Its initial value is "" (the root locale).Before a message catalog file is sourced by the procedure ::msgcat::mcload, the mc file locale is extracted from the message file name and stored as the current value.The mc file locale may be querried by the command ::msgcat::mcconfig -mcfilelocale.The mc file locale may also be set by the command ::msgcat::mcconfig -mcfilelocale value.The original message filename may not be reconstructed by: [::msgcat::mcconfig -mcfilelocale].msg; there can be case differences.
The command ::msgcat::mcconfig is shared with . It has a new option -mcfilelocale.
There are two new commands:
::msgcat::mcflset source ?translation?::msgcat::mcflmset list
These work as:
ICAgOjptc2djYXQ6Om1jc2V0IFs6Om1zZ2NhdDo6bWNjb25maWcgLW1jZmlsZWxvY2FsZV0gc291cmNlID90cmFuc2xhdGlvbj8=ICAgOjptc2djYXQ6Om1jbXNldCBbOjptc2djYXQ6Om1jY29uZmlnIC1tY2ZpbGVsb2NhbGVdIGxpc3Q=
The command name mcflset is an abreviation of: "message c'atalogue with file locale set'''".
The example of the Rationale section above may now be written as:
LWRlLm1zZy0=Ojptc2djYXQ6Om1jZmxzZXQgT3BlbiDWZmZuZW4=Ojptc2djYXQ6Om1jZmxzZXQgQ2xvc2UgU2NobGllc3Nlbg==LWVvZi0=
The locale value de only appears in the file name.
Further examples are in the tcl wiki msgcat page: []
See Tcl Feature Request 3544988. []
This document has been placed in the public domain.