forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: Heroe on November 20, 2009, 12:25:55 pm

Title: [Solved]: Menu link in different languages, how?
Post by: Heroe on November 20, 2009, 12:25:55 pm
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.

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


Title: Re: Menu link in different languages, how?
Post by: 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 (http://sourceforge.net/projects/coppermine/files/Themes/1.4.x/cpg1.4.x_theme_grey-style-20.1.0.1.zip/download) wich had a multilingual feature for link titles (of course you must addapt it)
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 20, 2009, 06:03:16 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 (http://sourceforge.net/projects/coppermine/files/Themes/1.4.x/cpg1.4.x_theme_grey-style-20.1.0.1.zip/download) 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 :(
Title: Re: Menu link in different languages, how?
Post by: François Keller on November 20, 2009, 06:16:06 pm
Quote
Thank 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  ;)
Title: Re: Menu link in different languages, how?
Post by: Joachim Müller on November 20, 2009, 06:20:39 pm
Use the variable $USER['lang'] to determine the user's language.
Then use an if/then switch. Could look like this:
Code: [Select]
<?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>';
}
?>
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 20, 2009, 07:26:26 pm
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 :

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

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

Code: [Select]
<?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  ???
Title: Re: Menu link in different languages, how?
Post by: François Keller on November 20, 2009, 07:31:09 pm
attach your theme folder on your next post (in a zip file)
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 20, 2009, 07:38:32 pm
This is the theme.



Title: Re: Menu link in different languages, how?
Post by: François Keller on November 22, 2009, 06:10:10 pm
Your theme works for me in different languages.
attached, french.php file for you  ;)
try to clear your cookies and browser cache
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 22, 2009, 09:10:52 pm
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
 
Title: Re: Menu link in different languages, how?
Post by: 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
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 22, 2009, 10:19:26 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
Title: Re: Menu link in different languages, how?
Post by: François Keller on November 22, 2009, 10:22:49 pm
Quote
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)
No chance, i'm near from Strasbourg
Title: Re: Menu link in different languages, how?
Post by: Heroe on November 22, 2009, 10:25:24 pm
 >:(
OK, thanks anyway
Title: Re: Menu link in different languages, how?
Post by: emjay_smitten on February 03, 2010, 01:41:09 pm
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
Code: [Select]
<?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
Code: [Select]
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
Title: Re: Menu link in different languages, how?
Post by: Joachim Müller on February 03, 2010, 10:23:41 pm
Yeah, whatever. If you think your code is better, use it. Locking.