coppermine-gallery.com/forum

Support => Older/other versions => cpg1.3.x Support => Topic started by: Kursk on July 27, 2004, 08:24:09 AM

Title: Language dependant content in anycontent.php
Post by: Kursk on July 27, 2004, 08:24:09 AM
I know it's anycontent, but is the following possible:

Display the content of anycontent.php in different laguages (simple text/links stuff, similar to what FAQ looks like.)  Add some extra into a whateverlanguage.php and have it pulled up in anycontent.php.

I'm talking 2 languages here (en/ru for example).  So as to when Russian is selected, visitors are greeted (in anycontent) with some text in Russian.  Same goes for English.
Title: Re: Language dependant content in anycontent.php
Post by: omniscientdeveloper on July 27, 2004, 08:44:28 AM
Sure!

:)


My philosophy is to try something before asking though. If I can't figure it out, then I'll ask "is it possible."

;)

The best thing to do though, is put your changes in an external language file and add an include statement in the language file of your choice. By doing it this way, you won't have to edit the actual language files when you do an update.

-- or --

You can do a check on the selected $USER['lang'] (I think) and include the file within anycontent.php. (maybe better than the first option)


-omni
Title: Re: Language dependant content in anycontent.php
Post by: Tarique Sani on July 27, 2004, 08:46:33 AM
If you want to have one anycontent for English and another for anyother  language have two files called (for example) englishaycontent.php and otheranycontent.php

in your anycontent.php write some thing like


if ($CONFIG['lang']=="english"){
include (englishanycontent.php);
}else{
include (otheranycontent.php);
}


Untested code but should work
Title: Re: Language dependant content in anycontent.php
Post by: Joachim Müller on July 27, 2004, 08:52:42 AM
You can use $USER['lang']. This could be the content of your anycontent.php file:<?php
if ($USER['lang'] == 'german') {
starttable("100%""Willkommen");
?>

<tr><td class="tableb" >
Herzliche Begrüssung auf Deutsch
</td></tr>
<?php
} else {
starttable("100%""Welcome");
?>

<tr><td class="tableb" >
Some greetings in english
</td></tr>
<?php
}
endtable();
?>


GauGau
Title: Re: Language dependant content in anycontent.php
Post by: Joachim Müller on July 27, 2004, 08:53:36 AM
hehe, nearly-simultaneous answer of three coppermine devs with nearly the same content  ;D

GauGau
Title: Re: Language dependant content in anycontent.php
Post by: omniscientdeveloper on July 27, 2004, 09:10:48 AM
Indeed. I saw that Tarique was looking at it, but when I refreshed it looked like he had left the thread, so I answered.  ::)
;D
Title: Re: Language dependant content in anycontent.php
Post by: Kursk on July 27, 2004, 04:26:19 PM
Thanks guys, appreciate it.  Exactly what I was looking for.

omniscient, I would have tried it had I known what I was doing.  I have been working with php for only a couple of weeks. html only prior to that.  That for sure doesn't make me omniscient in it, but whatever the opposite of that.  ;)
Title: Re: Language dependant content in anycontent.php
Post by: ypp on November 16, 2005, 01:33:09 AM
Hello...and if I want to do it for more than two languages, how should I modify the code below?  :-[ ???

<?php
if ($USER['lang'] == 'german') {
starttable("100%""Willkommen");
?>

<tr><td class="tableb" >
Herzliche Begrüssung auf Deutsch
</td></tr>
<?php
} else {
starttable("100%""Welcome");
?>

<tr><td class="tableb" >
Some greetings in english
</td></tr>
<?php
}
endtable();
?>



Thank you
Title: Re: Language dependant content in anycontent.php
Post by: Joachim Müller on November 16, 2005, 07:30:10 AM
<?php
if ($USER['lang'] == 'german') {
starttable("100%""Willkommen");
?>

<tr><td class="tableb" >
Herzliche Begrüssung auf Deutsch
</td></tr>
<?php
} elseif ($USER['lang'] == 'spanish') {
starttable("100%""Bienvenido");
?>

<tr><td class="tableb" >
Algo en Español
</td></tr>
<?php
} else {
starttable("100%""Welcome");
?>

<tr><td class="tableb" >
Some greetings in english
</td></tr>
<?php
}
endtable();
?>


With the actual code removed, just some pseudo-code to make the structure more obvious:<?php
if ($USER['lang'] == 'german') {
    
// german stuff here
} elseif($USER['lang'] == 'spanish') {
    
// spanish stuff here
} elseif($USER['lang'] == 'dutch') {
    
// dutch stuff here
} else {
    
// all other languages
}
?>
HTH
Title: Re: Language dependant content in anycontent.php
Post by: ypp on November 16, 2005, 11:16:01 AM
Thank you a lot GauGau for your answers and patience  :)