In the course of customizing Mozilla's Kitsune knowledge base website for Thunderbird (from the great Mozilla SUMO dev team, thanks jsocol and team!) software, I needed to change locale strings to reference Thunderbird instead of Firefox. Locale strings consist of:

  • msgid e.g. "Firefox Help"
  • followed by msgstr which is the localized version e.g. "Firefox-Hilfe" (for the German locale)

For Thunderbird I changed all occurences of Thunderbird to Firefox where there was a Thunderbird equivalent (I didn't change strings that have no Thunderbird equivalent e.g. there is no mobile version of Thunderbird so I left all mobile related strings unchanged). In the above example "Firefox-Hilfe" becomes "Thunderbird-Hilfe"

To do this automatically for all languages that the knowledge base for Thunderbird supports (which is dozens), I wrote a ruby script to do this: changeMessages-po-to-tb.rb

Of course this fails for languages where nouns are declined like Polish which in various situations uses "Firefoksa" instead of "Firefox" for example.

But it works for most of the locales and therefore has saved me and the localizers considerable time.

Is there a better way to do this? Perhaps a built in search and replace utilty in Linux or Mac OS X?