0

is there a way to use the "context" or "msgctxt" in Zend_Translate when I call the method $translator->translate('My String') ?

I need to classify the item to be translated to a specific context for instance:

  • Customer Administration
  • Shopping Cart
  • Order Administration

I need to use the contexts to solve ambiguities between the translation items.

At the moment I am using the PoEdit software and Zend_Translate to translate my project.

Thanks

Michelangelo
  • 1,398
  • 2
  • 14
  • 37

1 Answers1

0

I was searching this too, and it would seem that Zend_Translate does not support translation context.

You could try to extend the main Zend_Translate class and implement the translation context as some kind of prefix that is automatically used together with the sentence or terms to be translated, for example:

$translate->translate($context, $sentence);

would be internally managed as

parent::translate("$context|$sentence");

and

$translate->translate($context, array($singular, $plural, $num));

would be

parent::translate(array("$context|$singular", "$context|$plural", $num));

but this would require to have the string with the prefixed $context in your translation sources.

Matteo Tassinari
  • 18,121
  • 8
  • 60
  • 81