[Solved]: Menu link in different languages, how? [Solved]: Menu link in different languages, how?
 

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]

Main Menu

[Solved]: Menu link in different languages, how?

Started by Heroe, November 20, 2009, 12:25:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Heroe

Hello,
I have modified my theme this days and i add to my menu the google map mod, but i don't know what to edit in the menu to have the title,name in different language (en,fr etc.) .

This is what i add to the menu to appear the link.

<a href="location_map.php">» Посетени страни</a></p>

but ofcourse in the menu the link appear only in my language.

How to edit the menu and the .lang files to appear in different languages?

link: http://www.abroadbg.com

Thank you in advance



François Keller

The best way to do is to make lang files for your theme (so you d'ont have to re-apply the modifications if you have to upgrade).
have a look to the grey-style-20 thème wich had a multilingual feature for link titles (of course you must addapt it)
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Heroe

Quote from: François Keller on November 20, 2009, 02:48:31 PM
The best way to do is to make lang files for your theme (so you d'ont have to re-apply the modifications if you have to upgrade).
have a look to the grey-style-20 thème wich had a multilingual feature for link titles (of course you must addapt it)
Thank you for the advice François Keller but i don't have the skills to make lang files :(

François Keller

QuoteThank you for the advice François Keller but i don't have the skills to make lang files
it's relative simple, try to look in the theme i refer to understand how it works. For 4 yars, i had no idea what php was  ;)
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Joachim Müller

Use the variable $USER['lang'] to determine the user's language.
Then use an if/then switch. Could look like this:<?php
if ($USER['lang'] == 'english') {
    echo 
'<a href="location_map.php">» Location map</a></p>';
} elseif (
$USER['lang'] == 'german') {
    echo 
'<a href="location_map.php">» Karte</a></p>';
} else {
    echo 
'<a href="location_map.php">» &#1055;&#1086;&#1089;&#1077;&#1090;&#1077;&#1085;&#1080; &#1089;&#1090;&#1088;&#1072;&#1085;&#1080;</a></p>';
}
?>

Heroe

Thank you both for the great hints and advices, i did as François Keller now i start understanding how to make  lang files.
But i have other problem.
I create folder with 2 lang files inside the theme folder.
english.php and bulgarian.php, when i press the language flag under my gallery i am able to change the language, but the translated strings doesn't apper until i refresh all the page :-[ . What i can do.

The edits i did are :

in the top of my theme.php i add :

global $CONFIG;
define('THEME_IS_XHTML10_TRANSITIONAL',1); // Remove this if you edit this template until
                                           // you have validated it. See docs/theme.htm.

if (file_exists("./themes/water_drop/lang/{$USER['lang']}.php")) {

require "./themes/water_drop/lang/{$USER['lang']}.php";

}

else {

require "./themes/water_drop/lang/english.php";

}


and the part with the menu look like :

// HTML template for main menu
$template_sys_menu = <<<EOT
               
<div class="wireframemenu">

<p><h1 class="h1_wireframemenu">{$lang_water_drop['gal_menu']}</h1></p>   

<!-- BEGIN home -->
                       <p><a href="{HOME_TGT}" title="{HOME_TITLE}">» {HOME_LNK}</a></p>
<!-- END home -->


themes/water_drop/lang/english.php :

<?php
if (!defined('IN_COPPERMINE')) { die('Not in Coppermine...'); }

$lang_water_drop = array(
  
'gal_menu' => 'Menu',
  
'admin_menu' => 'Administration',
  
'user_admin_menu' => 'User Admin',
  
'friends' => 'Friends',
  
'location_map' => 'Visited Countries',
);


?>


What i did wrong  ???

François Keller

attach your theme folder on your next post (in a zip file)
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Heroe


François Keller

Your theme works for me in different languages.
attached, french.php file for you  ;)
try to clear your cookies and browser cache
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Heroe

Merci  François Keller for the time to try, but seems even after clearing the cookies and browser cache no changes, the lang change only if i click twice on the lang flag, ore refresh the page. Also thanks for the french language :). Any idea if this could be problem with my tags.  ???

Greetings Ivo
 

François Keller

oh yes, i didn't understant your issue first time, sorry, I have the same problem on my theme and didn't find how to solved this. Maybe a "real" dev can help us  :D
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Heroe

Quote from: François Keller on November 22, 2009, 10:05:28 PM
oh yes, i didn't understant your issue first time, sorry, I have the same problem on my theme and didn't find how to solved this. Maybe a "real" dev can help us  :D
haha, ok, i see this is not problem just with my theme only. Thanks for the help and the test, we should wait somebody else with more skills to help us :).

Anyway if u are Parisian send me by email yr mobile number ore email i must buy u a drink for the help (i live in Paris partly)

Thanks very much for the help

François Keller

QuoteAnyway if u are Parisian send me by email yr mobile number ore email i must buy u a drink for the help (i live in Paris partly)
No chance, i'm near from Strasbourg
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Heroe


emjay_smitten

Hi,

http://www.haiticontacts.com/pictures

(@ Joachim Müller, sorry bout the last time but it is frustrating sometimes ;))

I used the code provided here. I tried several options to. I found out I dont have to check the code
<?php
if ($USER['lang'] == 'english') {
    
//code to be executed //
} elseif ($USER['lang'] == 'german') {
    
//code to be executed //
} else {
    
//code to be executed //
}
?>


options, because you can just use
require ("{$USER['lang']}.php") ;

in theme.php as well.

To me it is obvious that upon loading the first time the theme.php reads out the prefered language and set the cookie. Then the code works fine. But upon changing the language it already executed the code and will not read the cookie again. Unless you refresh or click again on the language option in your page.

I have not figured out how to complete this. Maybe because theme.php is just for the layout and the code need to be on another page? Anyone?

Martin

Joachim Müller

Yeah, whatever. If you think your code is better, use it. Locking.