The perl code uses the same text domain, and same binding to end up using the same message catalogue as the C example. So again this code will output "notest" rather than "test" when run.

One thing that's caught me a couple of times is the use of the setting LC_MESSAGES in the call to setlocale. It's tempting to use LC_ALL which means that all text should be translated, but that does not work - I believe the reason is that a sublocale needs to be specified. The higher level locale may have sublocales with conflicting settings - for example an application that outputs messages in English could have Pounds or Dollars as currency.

The other thing to be aware of is that the call to bindtextdomain needs to be performed before that domain is used by the textdomain call.

About

Darryl Gove is a senior engineer in the Solaris Studio team, working on optimising applications and benchmarks for current and future processors. He is also the author of the books:Multicore Application ProgrammingSolaris Application ProgrammingThe Developer's EdgeFree Download