Multilingual site

Hello ! I just installed Zenphoto on my multilingual site (English/French). I wanted that the "introduction pages" for the different albums link directly (without thumbnails) to the first image of the corresponding article. I managed this. No problem !

The "Image pages" in English should have a navigation in French and the ones in English should have a navigation in English. The navigation is the only element that should change between the English and the French versions. The navigation comes via "php include" into the "image page".

How can I obtain this result without having to build albums for each of the languages?

I tried many tricks, but to no avail.

Any good idea to propose? Thanks a lot in advance.

Comments

  • Soleil Member
    Still no good idea to propose ?
  • simonef Member
    So if I got this right, you want to have a php code like
    `<?php<br />
    if ($L=="D"){

    include("germannav.php");

    }

    else{

    include("englishnav.php");

    }

    ?>`

    Since I'll soon get the same problem about English and German I tried copying a theme and adding a parameter in the URL. Seems to work fine, just that you'll have to edit every link in the theme. Since you only worry about the album (what about the images?) that should do.

    In the default I replaced
    `<?php printPageListWithNav("« prev", "next »"); ?>`
    with
    `<?php<br />
    if($_GET['L']=="D"){

    printPageListWithNav("« zurück", "vor »");

    }

    else

    {

    printPageListWithNav("« prev", "next »");

    }

    ?>`
    So if I want the german version I have to use `www.mydomain.de/album.php?L=D`.
    Still you'd have to change the links to the images like:
    `
    echo getImageLinkURL();

    if($_GET['L']=="D"){

    echo "&L=D";

    }

    ?>`" title=" ...
    and add the same in the image.php for the links back to the album.
    Tested only on a local xampp light.

    cu
    Simone
  • mandyrc Member
    Recently I use Zenphoto gallery in a site with 3 languages (Spanish-English-German). The problem was to get the images descriptions in this 3 languages. I search this site for a solution, but I can't find one. I analize de code and find how Zenphoto gets de image descriptions from the database.

    Then I modify a couple of scripts and voilá, problem solved. The solution was:

    1. In the table IMAGES:
    a)Rename the field DESC for DESC_ES
    b)Duplicate this field twice to get the other 2 languages (DESC_EN and DESC_DE)

    2. In /zenphoto/zen/functions-controller.php, I do this:
    a) Begin the script with: `session_start()` to load a session variable $_SESSION['gal_desc_idm'] that contains which language is loaded.
    b) `$gal_desc = $_SESSION['gal_desc_idm'];` // Asign to $gal_desc the value of $_SESSION['gal_desc_idm']
    c) Finally in this script add the following function:
    `function get_lang() {

    global $gal_desc;

    return $gal_desc;

    }`

    3. In /zenphoto/zen/class-image.php, I use the function get_lang() as parameter of the function getDesc() which is the function thats gets de image description. The modified script (lines: 89 & 90) is like this:

    `function getDesc() { return $this->get(get_lang()); }

    function setDesc($desc) { $this->set(get_lang(), $desc); }`

    With this changes I get the description for the actual language in my page. I hope somebody can use this tip and that Zenphoto developers include this feature in next releases. Sorry my bad english, I am cuban and my native language is Spanish.
  • Soleil Member
    Thanks a lot simonef and mandyrc. I had been a few days without computer (holidays!).

    I will test your two solutions and let you know. They seem both very interesting.
  • Hey mandyrc,

    great thing
    thanks =)

    Did that and added a lang.php in the zen folder:
    `<?php<br />
    session_start();

    if($_GET['L']=="E"){

    $_SESSION['gal_desc_idm']="desc_en";

    }

    else

    {

    $_SESSION['gal_desc_idm']="desc_de";

    }

    $loc="Location: ".$_SESSION['back'];

    header($loc);

    ?>`

    In the image.php of the them I added right after the first <?php
    `session_start();

    $_SESSION['back']=FULLWEBPATH . '/' . zpurl();`

    And in the HTML the links `<<br />
    a href="../zen/lang.php?L=D">Deutsch<<br />
    /a>|< a href="../zen/lang.php?L=E">English`

    What I like best about it: Now you can switch languages with just one click, and when you are logged in as admin you can even edit them all =)

    Planned things: Same thing for album descriptions and all the names.
  • Another thing to fix: in the administration you can't properly edit the album anymore.
    Fatal error: Call to undefined function: get_lang() in /var/www/vhosts/scrapsite.de/httpdocs/zenphoto/zen/class-image.php on line 86

    Gonna try to fix that one soon.

    Edit: done!
    Do the same you did to /zenphoto/zen/functions-controller.php
    also to admin-functions.php
  • Here I am again with another problem. Up to now I did not use the album.php page in the multilingual sites where I installed zenphoto. The method suggested by simonef worked perfecttly with the image.php page. I used for instance
    `<?php echo getPrevImageURL(); if ( $L=="F") {<br />
    echo "&L=F";

    }

    elseif ($L=="EN"){

    echo "&L=EN";

    }

    elseif ($L=="D"){

    echo "&L=D";

    }

    else {

    echo "&L=F";

    }

    ?>" `
    (or variants of this code) to get pages in different language versions.

    I thought it would be possible to use a similar method with the`<?php printPageListWithNav("«", "»"); ?>` navigation, but I could not find a way how to do this. I tried also to change the code in the template-functions.php under `function getPageURL`, but did not manage, probably because my php knowledge is not good enough.

    I would be grateful if somebody could help me to solve this problem of printPageListWithNav.
  • No brilliant idea to propose to solve my little problem ?
  • I have again a question regarding my multilingual site.

    I am using, as suggested here, the code
    `if ( $L=="FR") {
    echo "&L=FR";
    }
    elseif ($L=="EN"){
    echo "&L=EN";
    }
    elseif ($L=="DE"){
    echo "&L=DE";
    }
    elseif ($L=="ES"){
    echo "&L=ES";
    }
    else {
    echo "&L=FR";`

    to link to pages in the requested language with the corresponding navigation. I could not find out however where to add the code for "comments" and "search". Has anybody an idea?
  • acrylian Administrator, Developer
    You will have to write some code if you want to use something like that. Zenphoto does not support determining the language via url queries. We use cookies to set the language. Look at the dynamic-locale plugin.
  • Thank you, Acrylian.

    The problem is that my website is built in such a way that dynamic-locale plugin does not fit (introduction pages, navigation for the whole site on the left....).

    I will apply this plug-in in another website I am working on

    My question is where to put my code so that the function "Submit" links to the right page layout.
  • You can always use the `setupCurrentLocale()` function directly. Use whatever code you need to do a `setOption('locale', yourlanguage, false);` then call `setCurrentLocale();` to register it.
  • Thanks sbillard !

    You will excuse my poor knowledge of dealing with functions and perhaps explain me where I can find the ` setupCurrentLocale() function ``.`
  • acrylian Administrator, Developer
    You find all functions on our functions documentation.
  • Specifically, `setupCurrentLocale()` is in the lib-i18n.php script as are all the functions dealing specifically with localization.
  • Thanks again sbillard !

    Unfortuantely I cannot find the lib-i18n.php script. I guess it should be in zp-core (?!).

    What I cannot understand/find out is how after submitting a comment the link to the just used page is established. Could you explain me shortly how it works, which functions are involved in this process?

    Comments are very important for my website since I ask for identification help of some very rare plants and animals.
  • acrylian Administrator, Developer
    Well. that's because it is acutally named `functions-i18n.php`...;-)

    I don't understand your comment question. What is wrong with the standard comment usage?
  • Yes, now I found it!

    But before I try to understand the "locale" system, I would like to answer the second part of your message.

    As I explained above I am using (for several reasons) the following coding on my website.
    ``if ( $L=="FR") {

    echo "&L=FR";

    }

    elseif ($L=="EN"){

    echo "&L=EN";

    }

    elseif ($L=="DE"){

    echo "&L=DE";

    }

    elseif ($L=="ES"){

    echo "&L=ES";

    }

    else {

    echo "&L=FR"; `

    It works perfectly for the different pages (album and not album) but not when a user writes a comment on a page like `http://www.xxx.net/album/index.php?album=xxx&image=xxx.jpg&L=FR`.

    After the comment has been submitted, the user comes on a page `http://www.xxx.net/album/index.php?album=xxx&image=xxx.jpg`, that is to say without the L=FR extension and with a lot of errrors.

    How to arrange it that the extension is created after the submission of the message? I simply don't find the place in the zenphoto code where I could add my php coding for languages.

    I would be very thankful if you could help me on this issue.
  • acrylian Administrator, Developer
    Did you look at the comment form plugin? You can change the form itself and add something to the url query. Normally it adds a `#` (see the "action" part) to the url so you could add your language query to it.
  • It works perfectly !!!!!!! So simple ! How to thank you ?

    Now the code for comments on "image.php" is

    `
    echo "&L=FR";

    }

    elseif ($L=="EN"){

    echo "&L=EN";

    }

    elseif ($L=="DE"){

    echo "&L=DE";

    }

    elseif ($L=="ES"){

    echo "&L=ES";

    }

    else {

    echo "&L=FR";

    }?>" method="post">`
  • acrylian Administrator, Developer
    How to thank you ?
    There is a donate button on our homepage...;-)
  • 0h la la ! Will you forgive me? I shouted victory too quickly and did not check everything ... in fact the most important.

    I get the right page layout, but the comment is not registered! The "#" seems important. but if I keep it, I do not get the right layout! Probably my idea is not the right one.

    May I ask again for your help?

    The donation (my second one) is already on its way.
  • acrylian Administrator, Developer
    Since the comment submitting is done via POST why don't you add a hidden field for the language to the form and write a small function that either gets the language by query (GET) or by POST using $_REQUEST[].
  • Here I am again, after a long silence due to too much work.

    To finish this discussion, I would like to inform you, that after my attempts, using among others your suggestions, I finally rebuilt my site in order to use Zenpage. It solved the multilingual issue. Zenpage is GREAT !
Sign In or Register to comment.