how to program php array for automatic language translation?

Discussion in 'PHP' started by medaacek, Feb 26, 2010.

  1. #1
    Hello,

    I do not know almost anything about programing but need a help I have not found elsewhere:

    Im running joomla based multilingual site with joomfish static translations. Now I implemented a form that everybody can fill in and send. The form includes drop down field with english text-strings. Once the user saves the data, the english strings get saved in database - ket say the user opts for "Ostrich" from the drop donw so "Ostrich" gets saved in the database.

    The data from the database are then shown in a frontend as a table - it means "Ostrich" is shown as well.

    What I want is, when the visitor is from Czech Rep. and uses the cs-CZ language version, insted of seeing "Ostrich" in the table he would see the Czech translation "Pstros". So what I need is to filter that site (with the result table) every time and search for specific words and translate them according to the language chosen by the visitor. is this possible and how to do that?

    I got an advice to use php arrays and the define() function to call the translation script but I have no clue how to do that!

    The guy told me to make a file with the array like this e.g.:
    $bird_array = array();
    
    $bird_array['cs-CZ'] = array(
    'str_cam' => 'Pstros',
    'gav_ste' => 'Potáplice',
    and so on
    
    . . .
    );
    $bird_array['la-LA'] = array(
    'str_cam' => 'Struthio camelus',
    'gav_ste' => 'Gavia stellata',
    . . .
    );
    
    $bird_array['en-GB'] = array(
    'str_cam' => 'Ostrich',
    'gav_ste' => 'Red-throated Loon',
    
    . . .
    );
    
    Code (markup):
    and then to call this file by using the define() function from the site where I need the transaltion

    Does anybody know how to connect all these thing together to make it work? I think the language of the site is decided by the user preference so now the only question is how to make the whole script run (I know it is not really a script but as I said, I do nothing about programming).

    This all is gonna be a non profit web for users from all over the world so the translation function would make it much easier for those who dont speak English.

    Your help is very appreciated!!!

    Jiri
     
    medaacek, Feb 26, 2010 IP