Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Language dependant content in anycontent.php  (Read 5970 times)

0 Members and 1 Guest are viewing this topic.

Kursk

  • Translator
  • Coppermine newbie
  • **
  • Offline Offline
  • Posts: 14
    • anton-amy.com
Language dependant content in anycontent.php
« 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.
« Last Edit: November 16, 2005, 05:31:20 pm by GauGau »
Logged

omniscientdeveloper

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 901
Re: Language dependant content in anycontent.php
« Reply #1 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
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Re: Language dependant content in anycontent.php
« Reply #2 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

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

Untested code but should work
Logged
SANIsoft PHP applications for E Biz

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Language dependant content in anycontent.php
« Reply #3 on: July 27, 2004, 08:52:42 am »

You can use $USER['lang']. This could be the content of your anycontent.php file:
Code: [Select]
<?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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Language dependant content in anycontent.php
« Reply #4 on: July 27, 2004, 08:53:36 am »

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

GauGau
Logged

omniscientdeveloper

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 901
Re: Language dependant content in anycontent.php
« Reply #5 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
Logged

Kursk

  • Translator
  • Coppermine newbie
  • **
  • Offline Offline
  • Posts: 14
    • anton-amy.com
Re: Language dependant content in anycontent.php
« Reply #6 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.  ;)
Logged

ypp

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
Re: Language dependant content in anycontent.php
« Reply #7 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?  :-[ ???

Code: [Select]
<?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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Language dependant content in anycontent.php
« Reply #8 on: November 16, 2005, 07:30:10 am »

Code: [Select]
<?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:
Code: [Select]
<?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
Logged

ypp

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
Re: Language dependant content in anycontent.php
« Reply #9 on: November 16, 2005, 11:16:01 am »

Thank you a lot GauGau for your answers and patience  :)
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 20 queries.