Member
Member
mikegoodstadt   25-03-2009, 23:57
#1

I am revising the dynamic-locale plugin to display buttons rather than a pull down list. In this way I can then blend the buttons in with CSS to look like a typical pipelist. Check it out bottom left here: http://estudioa-2.com/

As you can see it works but the problem I have is that I cannot find the correct way to label the button. I want the button value (label) to be the 'language array key'/'language name' eg. Español. This however generates the error which says that the locale cannot be found on the server.

Now I suspect that this is because the getOption function called in the plugin is only appropriate for a select list and not for buttons. Is that assumption correct? How can I get around that - by writing another function to convert the value to the 'language array item'/'ISO code' ie. es_ES.

I include below the plugin in which, for simplicity, I also put the new functions rather than also hacking the functions and functions-i18n files. To toggle the error alternate between lines 46 and 47 (//if ($localize) $display = $key;...) . Please feel free to suggest more efficient methods or redundant code.

A second method I really would prefer to use is an unordered html list (UL) styled with CSS to make a flat/pipelist. I believe that to POST the locale selection would need a javascript call on anchor links around the language list items (LI). Can anyone illustrate to to do this alternate method correctly to avoid hassle with the buttons?

Of course if anyone can outline which of these two methods is best and why then I would be most grateful!

Mike

`

Member
Member
sbillard   26-03-2009, 05:59
#2

The 'option' must always be the language designator--the xx_XX version of the language.

There is an array $_zp_languages which can be indexed by the language designator to give you the display name of the language.

Member
Member
mikegoodstadt   26-03-2009, 07:34
#3

Just as in the original dynamic-locale I have tried using the $_zp_languages to generate the button label (uncomment line 41 / comment line 42). However as, unlike an option list, buttons have no option and will submit that label. Thus I am guessing that an additional process is required to switch the label back to the ISO code xx_XX. Can you confirm my supositions and offer a little guidance on the easiest way to do that swap?

Member
Member
mikegoodstadt   26-03-2009, 13:52
#4

Firstly I didn't say many thanks for all your work and getting back to me so quickly.

Apart from my comment above can you also help me understand how this form is handled? Is the hash a null or a page reload? I am sorry for the newbie questions but I am going round in circles and need someone to help me clear my head!

Many thanks,
Mike

Member
Member
sbillard   26-03-2009, 17:17
#5

Yes, you must switch back to the ISO code. That is what Zenphoto needs internally. You can use an array_flip of the $_zp_languages array and index it by the display language.

With the original plugin, when you change the selection of the drop-down the form is posted. The "action" takes you back to the same page and the post is processed by the zenphoto setupCurrentLocale() function. It is looking for a POST of 'dynamic-locale'.

So, somehow you need to make your buttons do a POST submit with a field of that name containing the ISO value of the language.

Member
Member
mikegoodstadt   27-03-2009, 09:27
#6

That's what I thought - the pointers you give are just what I needed.
Thanks!

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.