Language dependant content in anycontent.php Language dependant content in anycontent.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Language dependant content in anycontent.php

Started by Kursk, July 27, 2004, 08:24:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kursk

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.

omniscientdeveloper

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

Tarique Sani

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
SANIsoft PHP applications for E Biz

Joachim Müller

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

Joachim Müller

hehe, nearly-simultaneous answer of three coppermine devs with nearly the same content  ;D

GauGau

omniscientdeveloper

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

Kursk

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.  ;)

ypp

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

Joachim Müller

<?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

ypp

Thank you a lot GauGau for your answers and patience  :)