*) You don't need printf... the translation view helper supports this out of
the box.
*) Using placeholder you must keep aware of the string format you are using.
"%1\$s" is different to '%1\$s'
When the format you are using escapes the characters then you must add
another \ which would read
"%1\\$s"... but this depends on your format.
Note that this is plain php and has nothing to do with the adapter itself.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com----- Original Message -----
From: "aztechy" <
[hidden email]>
To: <
[hidden email]>
Sent: Saturday, June 27, 2009 12:41 AM
Subject: [fw-i18n] Zend_Translate using INI adaptor
>
> Hello all,
>
> Hoping to get pointed in the right direction here. Currently setting up
> our
> application to have translation. What I currently have going on are the
> following:
>
> In our bootstrap we set an instance of Zend_Translate and Zend_Locale in
> the
> registry as follows:
>
> Zend_Registry::set('Zend_Locale', new
> Zend_Locale(Zend_Registry::get('config')->locale));
> Zend_Registry::set('Zend_Translate', new Zend_Translate('ini',
> '../language/', null, array('scan' => Zend_Translate::LOCALE_FILENAME)));
>
> So now in the controller i can access Zend_Translate by pulling it out of
> the registry as such:
> $translate = Zend_Regsitry::get('Zend_Translate');
>
> Make translation calls like:
> print $translate->_('Some string I want translated');
>
> This all works perfect, my stumbling block is how to define the keys
> within
> my ini file if the translation text is kind of unkown. The zend writeup
> has
> an example using printf like:
> printf($translate->_('The date is %1\$s'), $date);
>
> So I figured I'd do something simple like translate a 'Hello <name>'
> string.
> The test call to this would seem to be:
>
> printf($translate->_("Hello %1\$s"), $name); // Where name is defined
> earlier to take user input.
>
> Then in my INI file I would define a key => translated text pair to look
> like:
> 'Hello %1\$s' = "Hola %1\$s'; // If this were the pair for my spanish
> file.
>
> However this doesn't work for a couple of reasons.
> 1) INI adaptor breaks it seems on keys that have '\' or '$' characters in
> them.
> 2) The call to translate above would turn my key into "Hello bobby", for
> example if value of name was bobby, and the translater not able to find
> the
> key would just output Hello bobby onto the screen and not "Hola %1\$s" or
> even Hola bobby.
>
> I obviously am missing something here, again if someone can point me in
> the
> right direction, it would be greatly appreciated.
>
> --
> View this message in context:
>
http://www.nabble.com/Zend_Translate-using-INI-adaptor-tp24228285p24228285.html> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.