Just thought of this, may not be a good idea, but worth a try!

Use the standard localization function __() as in the example below:

$html->image( __('btn_action.gif',true) );

and voila, you can decide to change the default image "btn_action.gif"
into something else depending on the language, by just specifying in
the language file, that "btn_action.gif" is equal to "eng/
btn_action.gif".

Haven't tried it, so you are on your own in testing it :)
Enjoy,
   John

On Jun 15, 3:25 am, "Adam Royle" <[email protected]> wrote:
> I guess it depends if you have any shared images that might be generic and
> used with all languages.
>
> If you want to override the helper, you can do it by creating an AppHelper
> class in app/app_helper.php
>
> Although this does change your functionality and you would have to duplicate
> any shared images between all languages.
>
> I would probably go the more explicit route, and just append the language to
> the image path ($lang = 'en/').
>
> $html->image($lang.'btn_action.gif');
>
> Cheers,
> Adam
>
> ----- Original Message -----
> From: "daedalus" <[email protected]>
> To: "CakePHP" <[email protected]>
> Sent: Monday, June 15, 2009 6:24 AM
> Subject: Modifying Html Helper Image method for localization support
>
> > Hello,
>
> > I'm fairly new to CakePHP and have a question about the best way to
> > accomplish a task. Here is my situation: I'm building a little
> > localized app that incorporates a dozen or so images that will need to
> > be localized - for example navigation buttons.  The most logical way
> > to organize these images, it seems to me, is to put the images for
> > each language into a folder bearing the language abbreviation in the
> > "img" directory.  So, for instance, English images would be in "img/
> > eng/".
>
> > The app is working nicely now with Html helper image calls such as
> > $html->image('btn_action.gif').  The language variable is written to
> > the Config class in a beforeFilter of the (only) controller.  Ideally,
> > I guess, I need to modify or extend the Html helper to automatically
> > add the correct language directory into the image path, but as much as
> > I've looked around for examples I'm still a bit hazy on how to best
> > accomplish this.  Can I overwrite the "image" method of the Html
> > helper by including an appropriate class in /app/helpers? Am I going
> > about this in the right way to begin with?  I'm not so much interested
> > in what merely works, but with what is most elegant, logical, and
> > maintainable.
>
> > Thanks a lot,
>
> > AH
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to