Very nice question (+1). There was some discussion on one of the Drupal mailing lists back in 2006, I believe. The core devs fiercely defended the current design of the i18n and l10n infrastructure. The problem of homonyms for Indoeuropean languages is limited, but when you move for example to China, that becomes overwhelming as each ideogram in Chinese represent a bunch of very different concepts, and you can get the intended one only by looking at the context.
Although there is not a coded solution for homonyms, there is a very simple best practice: provide context! Whenever possible feed the t() function with sentences, not single words, or to say it with the code documentation in common.inc
:
When using t(), try to put entire sentences and strings in one t() call. This makes it easier for translators, as it provides context as to what each word refers to.
When this is not possible, and using a synonym with a different spelling is not an option, you could embed transparent HTML tags providing context for translation. For example:
$heading = "<h2>" . t("<span id="product-as-in-stores">Product</span>") . "</h2>";
This way you provide essential information to translators, while if you had simply embedded the <h2>
tags, the translator would have to guess what product refers to.
This is - BTW - one of the very few cases where embedding HTML tags in t() strings is not considered bad.
HTH!