2

Currently, I'm trying to apply Zend_Translate to the project I'm working on. Regular text works perfectly fine, but I ran into a problem with the translation of forms.

The translation adapter is registered in Zend_Registry, using Zend_Translate as key. This works fine for most of the time, except for when the translation should happen before displaying the form.

Code example:

$subformBusiness->setLegend(_('Bedrijfsgegevens') . ':');
$subformBusiness->setLegend(_('Bedrijfsgegevens'));

Assuming 'Bedrijfsgegevens' is translated in the corresponding translation source files, the upper line will be outputted as 'Bedrijfsgegevens:', whereas the lower line outputs 'Business information'.

As far as I know, there are three ways of solving this. It can be solved by calling the stored Zend_Translate_Adapter before concatenating it with the colon, but that gives a lot of unnecessary code. Another option is to incorporate punctuation in the translation files, but that would mean there should be a translation for each type of punctuation. The thrid option is to simply remove the colon from the legend, but that's not what I'm looking for.

My question: is there a way to tell Zend_Translate to disregard punctuation?

Lex
  • 293
  • 1
  • 5
  • 15
  • will it not work if you don't concatenate the colon? $subformBusiness->setLegend(_('Bedrijfsgegevens:')); Will this break translate? – RockyFord Jan 27 '12 at 12:27
  • That would work, but I don't want to add 'Bedrijfsgegevens', 'Bedrijfsgegevens.' and 'Bedrijfsgegevens:'. Lacking another method, I'm using this, but I would've preferred using something more generic. – Lex Jan 28 '12 at 08:43

2 Answers2

0

As far as I know, Zend_Translate works only with literal strings, and it doesn't contain any punctuation functionality. What I would do would be just to remove the colon from the legend (your third option) and add it afterwards somehow (for instance, using the :after CSS property).

Hope that helps,

dinopmi
  • 2,683
  • 19
  • 24
0

Why don't you add the punctuation to the strings? OK, you will have to translate both 'Legend' and 'Legend:', but that works perfectly for me.

E.g.:

$subformBusiness->setLegend(_('Bedrijfsgegevens:'));
$element->setLabel('This is a great label:');
guhemama
  • 107
  • 3
  • 7