views:

21

answers:

1

Does anybody know a high-quality yaml adapter for Zend Framework's Zend_Translate?

There seems to be a proposal in the Zend project itself, but it's been inactive for years.

+2  A: 

Not aware of an adapter. There is a Zend_Config Adapter for YAML files in the incubator though and PHP has a PECL extension for YAML. There is also the YAML Symfony Component. You could use those to convert your translation files to array and then pass that array to the array adapter, but then again, using one of the source formats might be more feasible then.

Gordon
Nice idea! The problem would probably be, though, that the Array adapter can't deal with nested yaml structures (`Loginform` -> `Texts` -> `WelcomeMessage`). But neither can Zend_Translate, so I may indeed fare best by converting the yaml into an array with static keys at some point: `$dictionary["Loginform:Texts:WelcomeMessage"] = "Welcome!"`. Maybe even outside the app in a cached form. Will check whether the Zend_Config adapter can help me do it.
Pekka
@Pekka in the project where I use the Array adapter, I use labels like 'button.submit' => 'Senden' or 'button.cancel' => 'Abbrechen' or 'models.user.username' => 'Benutzername', etc. It's more typing than with indented YAML, but it helps for grouping the labels.
Gordon
@Gordon yup, this makes sense. (See also my update to my comment above, it overlapped with yours.) I love yaml for maintenance because it's so clean - maybe I'll write a "compiler" so the application has the stuff in array form.
Pekka