Tcl Source Code

View Ticket
Login
Ticket UUID: 3544988
Title: Add msgcat current file local
Type: RFE Version: None
Submitter: oehhar Created on: 2012-07-17 09:32:28
Subsystem: 30. msgcat Package Assigned To: oehhar
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2013-05-08 15:55:46
Resolution: Accepted Closed By: oehhar
    Closed on: 2013-05-08 08:55:46
Description:
Message catalog files have names: "<locale>.msg" and consist of entries like:
mcset <locale> <ori> <translation>

Example:
--de.msg--
mcset de File Datei
mcset de Exit Verlassen
--eof--

The locale is repeated for each command, even if it could be known by the file name.
I often do errors here specially if I copy- and paste message catalogue file contents and forget to change the locale.

The feature request proposes the notion of a locale generated from the message catalog file name which is extracted and stored in the msgcat package.

Interface:
Get MC File locale:
msgcat::mcconfig -mcfilelocale
It might also be set (for example within message files):
msgcat::mcconfig -mcfilelocale de_CH
A new mcset uses this mc file locale implicitly:
msgcat::mcflset <ori> <translation>
And its multi-counterpart:
msgcat::mcflmset {ori1 trans1 ori2 trans2 ...}

Example use:
--de.msg--
mcflset File Datei
mcflset Exit Verlassen
--eof--

Attached is a ready to use msgcat-1.5.1.tm file and a diff against msgcat-1.5.0.tm from TIP 399 contained in feature request # 3511941
User Comments: oehhar added on 2013-05-08 15:55:46:
Implemented in msgcat 1.5.0

oehhar added on 2012-09-05 19:26:12:

File Added - 452637: msgcat.test.diff

oehhar added on 2012-09-05 19:25:43:

File Deleted - 452636:

oehhar added on 2012-09-05 19:25:16:

File Added - 452636: msgcat.tcl

oehhar added on 2012-09-05 19:22:45:

File Deleted - 452633:

oehhar added on 2012-09-05 19:19:43:

File Added - 452635: msgcat.tcl.diff

oehhar added on 2012-09-05 19:15:34:

File Added - 452633: msgcat.test.diff

oehhar added on 2012-09-05 16:03:27:
Donal,
thank you adding the mcconfig command in fossil:
http://core.tcl.tk/tcl/info/674aa977f0

I personally liked your idea to not expose it to the user.
I would only make it nest-proof.

If the TIP-Version is used, you should not set the file locale value to the empty string after an mcload. At least, it was intended, that this value changes and holds the last locale of mcload.
Reason? Transparency, thats all.
If a user sets it intentionally to a value, this value will anyway be lost be an mcload. So, I thought it is clearer to set it defined to one value.
But I really prefer the magic solution, that mcflset only works within mcload and thats all.

I will add a sample file as an attached file here.
I still have no fossil login (I am aware of), so no direct change.

Thank you,
Harald

dkf added on 2012-08-28 17:11:26:
That's OK; that's why we review before committing to a production branch. :-)

oehhar added on 2012-08-28 14:22:36:
Sorry, the comment about the clock command is wrong.
Of cause, package require msgcat 1.4 would load msgcat 1.5

No change necessary.

oehhar added on 2012-08-28 14:09:53:
Thank you for the branch and the documentation.

I have the following remarks:

1) clock.tcl explicitly requires msgcat 1.4 - if version 1.5 is used, this must be changed.

2) the part with the mcconfig command was removed, which is also contained in the tip.
  I personally like such opaque things where the file locale may be accessed, but this is not mandatory.

3) if the file locale is hidden to the user (by removing the mcconfig command), I would add a bit code to
  treat recursive calls to mcload:
  if {[info exists FileLocale} {set FileLocaleUp $FileLocale}
  ...
  if {[info exists FileLocaleUp]} {set FileLocale $FileLocaleUp} else {unset FileLocale}

4) msgcat.test
  - The easiest would be to copy the whole msgcat-5.* tests and repeat them with mcflset commands
  - In addition:
  - Add a test where mcflset is called outside an mcload -> error message
  - Add a test where mcload commands are nested

Thank you,
Harald

dkf added on 2012-08-28 02:56:03:
I've committed the code to the tip-404 branch (minus the part which required TIP 399 to be meaningful). I've also started writing some documentation, though an example of how to use (particularly mcflmset) would help that. Adding some tests would also a really good idea. :-)

I assume you know how to go to https://core.tcl.tk/tcl/timeline?r=tip-404 and look at what I've done?

oehhar added on 2012-07-25 21:55:01:
Implementation updated: mcflset and mcflmset did not detect the callers namespace properly

Sorry for the error,
Harald

oehhar added on 2012-07-25 21:53:58:

File Added - 449789: msgcat-1.5.1.zip

oehhar added on 2012-07-25 21:52:31:

File Added - 449788: msgcat-1.5.1.tm

oehhar added on 2012-07-25 21:51:00:

File Added - 449787: msgcat-1.5.0-1.5.1.patch

oehhar added on 2012-07-25 21:49:54:

File Deleted - 449764:

oehhar added on 2012-07-25 18:52:29:

File Added - 449764: msgcat-1.5.1.zip

oehhar added on 2012-07-25 18:50:50:

File Deleted - 449760:

oehhar added on 2012-07-25 17:02:29:

File Added - 449760: msgcat-1.5.1.tap

oehhar added on 2012-07-17 16:34:24:

File Added - 449131: msgcat-1.5.1.tm

oehhar added on 2012-07-17 16:32:55:

File Added - 449129: msgcat-1.5.0-1.5.1.patch

Attachments: