fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Tcl/Tk

New features in – part 5:

msgcat supports custom locale search list.

This is a nice one! When you are working in multi-lingual environments, you may want to translate strings according to your locale. But when there is no translation, msgcat falls back to some predefined other locales (or the "root" locale). But what if you want Japanese and failing that you like to keep English instead unless there is a German translation available?

You can do that now in Tcl9! You then just specify:

% msgcat::mcpreferences jp de en {}

That will make msgcat look for a Japanese translation first. It none is found, it looks for a German one and failing that for an English one.

Read more about this and some other enhancements here:

🔗 core.tcl-lang.org/tips/doc/tru

core.tcl-lang.orgTcl Improvement Proposals: TIP 499: Custom locale search list for msgcat

Pitfall of the day:

Try this:

foreach {name value} {
one 1
two 2
three 3
} {
set name($value) $name
}

Can you guess what is wrong ...?

Yes, you get the error

⚠️ can't set "name(1)": variable isn't array

That is because the plain loop variable 'name' gets defined first, before the loop body defines the array variable 'name'. But at that point, the variable name 'name' is already taken. Ups!