Menu

#625 Add msgcat current file local

closed-accepted
9
2014-08-26
2012-07-17
No

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

Discussion

  • Harald Oehlmann

    Harald Oehlmann - 2012-07-25

    patch to msgcat 1.5.0 from feature request #3511941

     
  • Harald Oehlmann

    Harald Oehlmann - 2012-07-25

    Ready to use tcl module including also feature request #3511941

     
  • Harald Oehlmann

    Harald Oehlmann - 2012-07-25

    Ready to use package: msgcat.tcl, pkgIndex.tcl and msgcat-1.5.1.tap for TclApp

     
  • Harald Oehlmann

    Harald Oehlmann - 2012-07-25

    Implementation updated: mcflset and mcflmset did not detect the callers namespace properly

    Sorry for the error,
    Harald

     
  • Donal K. Fellows

    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?

     
  • Donal K. Fellows

    • priority: 5 --> 9
     
  • Harald Oehlmann

    Harald Oehlmann - 2012-08-28

    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

     
  • Harald Oehlmann

    Harald Oehlmann - 2012-08-28

    Sorry, the comment about the clock command is wrong.
    Of cause, package require msgcat 1.4 would load msgcat 1.5

    No change necessary.

     
  • Donal K. Fellows

    That's OK; that's why we review before committing to a production branch. :-)

     
  • Harald Oehlmann

    Harald Oehlmann - 2012-09-05

    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

     
  • Harald Oehlmann

    Harald Oehlmann - 2013-05-08

    Implemented in msgcat 1.5.0

     
  • Harald Oehlmann

    Harald Oehlmann - 2013-05-08
    • status: open --> closed-accepted