Advanced search  

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

Pages: [1]   Go Down

Author Topic: [Solved]: Menu link in different languages, how?  (Read 8849 times)

0 Members and 1 Guest are viewing this topic.

Heroe

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
[Solved]: Menu link in different languages, how?
« 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


« Last Edit: February 03, 2010, 10:24:09 pm by Joachim Müller »
Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #1 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)
Logged
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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #2 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 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 :(
Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #3 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  ;)
Logged
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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Menu link in different languages, how?
« Reply #4 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>';
}
?>
Logged

Heroe

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #5 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  ???
Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #6 on: November 20, 2009, 07:31:09 pm »

attach your theme folder on your next post (in a zip file)
Logged
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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #7 on: November 20, 2009, 07:38:32 pm »

This is the theme.



Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #8 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
Logged
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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #9 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
 
Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #10 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
Logged
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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #11 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
Logged

François Keller

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 9094
  • aka Frantz
    • Ma galerie
Re: Menu link in different languages, how?
« Reply #12 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
Logged
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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 124
    • abroadbg.com
Re: Menu link in different languages, how?
« Reply #13 on: November 22, 2009, 10:25:24 pm »

 >:(
OK, thanks anyway
Logged

emjay_smitten

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Menu link in different languages, how?
« Reply #14 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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Menu link in different languages, how?
« Reply #15 on: February 03, 2010, 10:23:41 pm »

Yeah, whatever. If you think your code is better, use it. Locking.
Logged
Pages: [1]   Go Up
 

Page created in 0.069 seconds with 19 queries.