There are different contents types in Tk. Here text and icons are of special interest. These contents is accessible through the properties of a window.
Jeszra generates Option Database entries for these properties, which allows customization and localization.
In addition, the Tk MsgCat package can be used. Usage and Local are defined inside the »MSG Catalog« preference page under the »Generate« section. The page is shown in Figure 7.3, “Message Catalog Preferences”.
Figure 7.3. Message Catalog Preferences
The Message Catalog is loaded and the localized text stored in the Option Database. The generated code looks like Example 7.10, “Message Catalog Usage”.
Example 7.10. Message Catalog Usage
namespace eval top_1 { # Message Catalog # Requires Tcl/Tk version > 8.0 # Uses a subdirectory of project to locate the # Message Catalog for template 'top_1'. # namespace eval top_1 {} # package require msgcat namespace import ::msgcat::mc ::msgcat::mcload [file join \ [file dirname [info script] ] {top_1} ] option add *Top_1$w(1).text [mc {Test}] option add *Top_1$w(2).text \ [mc {Message Catalog}] ... }
Contents Editors
Figure 7.4, “Hugelist” displays the embedded »Modify Content« editor inside the Inspector. This editor can be used to alter the contents of certain windows, for example listboxes.
Embedded editors are provided for a series of listbox controls.
Text windows are edit able, too; but direct editing is preferred and used for the text window. Text tags appear inside the hierarchy view, under the text node. Text tags are customizable in the same way as any other item.
Figure 7.4. Hugelist
Additional Elements in the Hierarchy View
Hugelist entries are treated like normal items. They appear inside the hierarchy view, underneath the hugelist window, as shown in Figure 7.5, “Hugelist Entries”. Many more such elements exist in Jeszra: Text tags, toolbar items, menu entries, hugelist entries, images, gradients, styles, tabset items...
Hugelist entries are treated like normal items. They appear inside the hierarchy view, underneath the hugelist window, as shown in Figure 7.5, “Hugelist Entries”.
Many more such elements exist in Jeszra: Text tags, toolbar items, menu entries, hugelist entries, images, gradients, styles, tabset items...
Figure 7.5. Hugelist Entries
It would be possible to incorporate the message catalog code generation to allow for dynamic language changes. To achieve dynamic language changes: all message catalog Option Database entries must be place inside a procedure and this procedure has to be called after the local changed. In addition, all instances of the given template must be notified and a Option Database lookup performed for all the relevant data.
I don’t think dynamic language changes is an important functionality, yet.
Message Catalog related Code Generation
proc dumper::resourceMsgCat { rwindow rname value } { return [subst -nocommands \ { option add $rwindow.$rname \ [mc "$value"];}] }
Create a Option Database entry for a message catalog string. The message catalog is always deployed this way! A namespace is required. The generated Tcl-code can still utilize X Resource Database & Option Database modifications. The Option Database code is much more efficient than using »mc« on the command line.
proc dumper::resourcesMsgCatT template { return [subst -nocommands \ -nobackslashes \ { # ... package require msgcat namespace import ::msgcat::mc ::msgcat::mcload [file join \ [file dirname \ [info script] ] \ {$template} ] }] }
The Message Catalog usage call; placed inside a namespace eval block.
In comparison to MsgCatT: The template version uses a subdirectory named after the template to search for the message catalog. The non-template version assumes the message catalog lies inside the project directory.
Both »resourceMsgCat« and »resourcesMsgCatT« are parts of the Tcl-back end, implemented inside vg26/library/tcldumper.tcl.
vg26/library/tcldumper.tcl
Copyright © 2009–2010 Arndt Roger Schneider