Help - dynamic locale without form, and printPageListWithNav

Question 1:
My website is completely divided into two languages - English and Polish. When someone opens the gallery from a polish page, I would like the language used to be polish, and when opened from an english page - english. All my English pages are prefixed with en_ and all the Polish ones with pl_. How can I use the fact that there will be two separate links for two separate languages to automatically open ZenPhoto with the correct language from that link without having to use the form printLanguageSelector gives?

Question 2:
I use printPageListWithNav, but I would like for this whole nav bar to not appear if I only have 1 page. I assume the method will look something like this:
<?php if ($numPages != 1) { printLanguageSelector(); } ?>
But I have no idea what $numPages really should be. Can anyone help me with this, and tell me how to find this for myself in the future? I tried looking for something that might work here but I couldn't find anything I'd know how to use to solve this:
http://www.zenphoto.org/documentation/functions/_template-functions.php.html

Comments

  • #1. This might not be needed. If you set the language to HTTP Accept Language then zenphoto will run in the users preferd language as specified by his browser. One would expect that the English viewers perfered language would be English and the Polish ones Polish.

    If this is not the case you will have to set a cookie for the users declaring the language they should use. I think you can cause this to happen by using a SUBMIT method to link to the zenphoto index.php passing a parameter of `dynamic-locale` set to the correct locale tuple. I have not tried this, though. If it does not work you will have to come up with some other way to set the cookie.

    #2. The function you want is `getTotalPages()`. The way you find something like this is to search the docs page for phrases which might be in the function name. In this case `pages` quickly yielded the answer. ('page` came up with many 'false" matches so it was not as useful, but did lead to the function eventually.) Unfortunately, it is a matter of making educated guesses until you become more familiar with the functins.
  • Thank you very much!

    1- I have to try this, as everything in my PC is set to English, I'll ask someone with Polish settings to try my gallery now. On the other hand, I would love to be able to have some variable or cookie set when people click on one of the two buttons when you enter my site: english | polish
    So if they click on Polish, php does something that will let zenphoto know it should load the polish locale when they eventually get to the gallery. You said I should set a cookie using SUBMIT. If I wanted to use SUBMIT I would need to change those english | polish links into form buttons, I'd rather not do this. I will read some php tutorials on setting a cookie without using forms, could you link me to a page that will tell me what content must appear in this cookie?

    2- Thank you again!
  • You could use PHP...And create a function...
    Ex link:
    http://domain.com/index.php?lang=en
    http://domain.com/index.php?lang=pl
  • I would like to do that, ?lang=en, but what is the name of the language function that Zenphoto would honor (is it ?lang or was that just an example?), and how would I get that function to apply to all albums and images, until the user goes back to the main page and chooses ?lang=pl
  • If the index.php discovers `$_POST['dynamic_locale']` is set (Which happens when a form has done a submit with one of the imputs named `'dynamic_locale'` it will set the language to that value. This is how the dynamic_locale plugin works--you select a language and a submit is done with the appropriate parameters.

    So your could put a button on your form with the following:

    `




    `
    for the English one. I'll leave the Polish version to you--I am not fluent ;)

    Cookies seem really tricky. I have not found how to set a cookie for zenphoto from outside of the zenphoto folders.
  • But if he uses links, does he need to use a form?
    He said "How can I use the fact that there will be two separate links for two separate languages to automatically open ZenPhoto with the correct language from that link without having to use the form printLanguageSelector gives?"

    Cant he do something like
    index.php?dynamic_locale=en_US
  • Yes, the processing of the language happens only on a form submission.
  • acrylian Administrator, Developer
    This little javascript turns any normal link into a submit button (we use that for the "view slideshow" link):
    `.submit()">`
  • I CANNOT use a form for launching Zenphoto, since that would completely destroy the menu.
    www.panopixel.org

    Currently the gallery button links to a fubar page, but it normally would link to http://www.panopixel.org/zenphoto/

    Now that ZenPhoto supports more than 1 language, could I change that link to:
    for example?

    code wrote "index.php?dynamic_locale=en_US" and you wrote "yes", so I can use that? That is an option that would suite me, if it works.
  • acrylian Administrator, Developer
    The "yes" by sbillard refered to if using a form is required. Zenphoto gets the language info via $_POST, but using ?lang=en would need $_GET.

    Why can't you just use our language selector. Of course I know that this standard dropdown may not fit in style, but you could use my snippet from above to make two links for switching instead of the dropdown. Also you then could skip this entry page (which is not SEO friendly by the way).
  • I do not understand why you cannot use a form. In my example it shows just as a button. I am sure with a little research you can find a way to have a link do a submit as well.
  • acrylian Administrator, Developer
    I actually already posted that solution above.
  • Sorry I didn't get back to you sooner.

    Please take a look at my site www.panopixel.org
    The user has to select a language only once the first time he enters my site and never again. Since they enter for example into the English section, everything is in English. All links in the menu are in english, and one of those links points to zenphoto. I cannot replace one of the menu links with a form button because although I know its possible to replace a form button with an image, I think it it's not cross-browser safe and I dont know if it will work without javascript, and having a language selector in the gallery isn't consistent with the rest of the site anyway.

    Is seems pretty important to me that zenphoto should allow languages to be selected using a variable in a url, e.g. http://domain.com/index.php?lang=en
    If need be, that selection can then be saved by some zenphoto script in the index.php file so that all other zenphoto pages respect it.

    So two questions now:
    1- is it possible to make zenphoto respect the language that the user chose for the rest of my site without using a form (ie. using something that I can put in that menu of mine), and
    2- if the answer to 1 is 'no', then what if I change the two links on the main www.panopixel.org page into form buttons, knowing that the user will have to choose english or polish on that page to go further, then get taken to the main page in the chosen langage, and only then can he launch zenphoto, will the $post from the main page still 'hold' several pages away? I hope I wrote this clearly... there is at least 1 intermediate page between the language selection and zenphoto, often more than 1, so will a $post click on page 1 still exist when someone changes page 1 to page 2, 3, 4 and then page 5 which is zenphoto?
  • I just tested with some people and it opens in English for everyone, even for Poles... what could be wrong?
  • Sorry, but if you wish to make this work you will have to take one of the suggestions made above. Zenphoto does not provide to pass the language as a query parameter.

    The above suggestions seem like reasonable solutions. There if you use acrylian's suggestion your site will look no different than it does now so I don't know what your problem is.
  • acrylian Administrator, Developer
    The js snippet I posted above is fairly normal js stuff, nothing really tricky, and should really be cross browser.
Sign In or Register to comment.