Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created April 1, 2014 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/9916793 to your computer and use it in GitHub Desktop.
Save Ocramius/9916793 to your computer and use it in GitHub Desktop.
<?php
class AggregateTranslator implements YADDATranslator
{
/** @var YADDATranslator[] */
private $translators = [];
// ...
public function translate($string)
{
foreach ($this->translators as $translator) {
if ($string !== ($translated = $translator->translate($string))) {
return $string;
}
}
return $string;
}
}
@bartmcleod
Copy link

Thanks Marco! My problem is a little different but I think it comes down to this:

  • First assumption: the strings are not yet translated
  • In case of a configured MvcTranslator, is has several text domains under the patterns key
  • I want to translate forms, including placeholder attribs, labels and error messages to use a specified text_domain, other than 'default'.
  • The challenge is to propagate the text_domain to all of these stakeholders with a minimum amount of code and in such a way that the text_domain is actually used by the view helpers that do the actual translations upon rendering.
  • Today on irc DASPRiD agreed that translations aren't good yet for forms in ZF2, but I think this shouldn't be too hard to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment