Vous n'êtes pas identifié.
Annonce
Annonce 1 : Le Codex en français a besoin de vous pour avancer !
Annonce 2 : Avant de poster, n'oubliez pas de faire une petite Recherche et de lire les règles de ce forum.
Annonce 3 : Lisez notre blog, il regorge de bonnes informations.
#1 30-06-2008 17:14:49
- nlex
- Expert WP
- Date d'inscription: 14-02-2007
- Messages: 258
[Résolu] Transformation d'un theme en multilingue
Bonjour, j'ai presque fini de traduire mon theme en anglais/français mais je bloque sur un truc :
j'ai un menu en Javascript, apparemment d'apres l'auteur du plugin Language Switcher ça ne pose pas de problème, il suffit d'appliquer cette méthode :
I can program a little in PHP, and I want to know if there is a way I can do something in PHP that detects what language the blog viewer has chosen in the Language Switcher.[/b]
Yes, you can. There is a global variable in the Language Switcher called $langswitch_lang_pref, which gets set to the 2-letter language code currently in effect. So you can do something like this:Code: php
if( $langswitch_lang_pref == 'ru' ) { // do something if the language is Russian } else { // do something different if the language is not Russian }Note that if this is inside of a PHP function, you will need to add this line, inside your PHP function, just before the lines above:
global $langswitch_lang_pref;
Voila comment je l'ai appliqué, mais je ne connais rien en PHP !!
Code: php
- <body onload="preloadImages()">
- <div id="menu">
- <?php if( $langswitch_lang_pref == 'fr' ) {?>
- <a href="?cat=15"
- onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02.gif'); return true;"
- onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
- <img id="ag_2_02" src="/wp/wp-content/themes/simple/images/ag_2_02.gif" width="60" height="19" border="0" alt="projets"/> </a>
- <?php } else { ?>
- <a href="?cat=15"
- onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02_en.gif'); return true;"
- onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
- <img id="ag_2_02_en" src="/wp/wp-content/themes/simple/images/ag_2_02_en.gif" width="60" height="19" border="0" alt="projects"/> </a>
- <?php } ?>
- <a href="?page_id=12"
- onmouseover="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
- onmouseout="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04.gif'); return true;"
- onmousedown="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
- onmouseup="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;">
- <img id="ag_2_04" src="/wp/wp-content/themes/simple/images/ag_2_04.gif" width="35" height="19" border="0" alt="information"/> </a>
- <a href="/wp/?page_id=15"
- onmouseover="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
- onmouseout="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06.gif'); return true;"
- onmousedown="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
- onmouseup="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;">
- <img id="ag_2_06" src="/wp/wp-content/themes/simple/images/ag_2_06.gif" width="62" height="19" border="0" alt="contact"/> </a></div>
Biensur ça ne marche pas…
WP 2.5.1 plugins : cformII, feedsmith, getcustomfields, postthumb rev, wp-phpmyadmin, language switcher…
Hors ligne
#2 30-06-2008 17:23:44
Re: [Résolu] Transformation d'un theme en multilingue
Comme il l'indique, essaye en ajoutant la ligne global $langswitch_lang_pref; au début.
Par exemple:
Code:
- <?php
- global $langswitch_lang_pref;
- if( $langswitch_lang_pref == 'fr' ) {?>
Mais globalement, je ne vois pas la différence entre tes deux code (avant le ELSE et après).
Hors ligne
#3 30-06-2008 18:26:24
- nlex
- Expert WP
- Date d'inscription: 14-02-2007
- Messages: 258
Re: [Résolu] Transformation d'un theme en multilingue
Oui il manquait ça et un problème de syntaxe je crois, maintenant ça marche
Code: php
- <div id="container">
- <div id="nav">
- <img id="ag_2_01.gif" src="/wp/wp-content/themes/simple/images/ag_2_01.gif" alt="alexis godefroy, design graphique"/>
- <div id="menu">
- if( $langswitch_lang_pref == 'fr' ) { ?>
- <a href="?cat=15"
- onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02.gif'); return true;"
- onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
- <img id="ag_2_02" src="/wp/wp-content/themes/simple/images/ag_2_02.gif" width="60" height="19" border="0" alt="projets"/> </a>
- <?php } else { ?>
- <a href="?cat=15"
- onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02_en.gif'); return true;"
- onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
- onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
- <img id="ag_2_02_en" src="/wp/wp-content/themes/simple/images/ag_2_02_en.gif" width="60" height="19" border="0" alt="projects"/> </a>
- <?php } ?>
- <a href="?page_id=12"
- onmouseover="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
- onmouseout="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04.gif'); return true;"
- onmousedown="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
- onmouseup="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;">
- <img id="ag_2_04" src="/wp/wp-content/themes/simple/images/ag_2_04.gif" width="35" height="19" border="0" alt="information"/> </a>
- <a href="/wp/?page_id=15"
- onmouseover="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
- onmouseout="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06.gif'); return true;"
- onmousedown="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
- onmouseup="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;">
- <img id="ag_2_06" src="/wp/wp-content/themes/simple/images/ag_2_06.gif" width="62" height="19" border="0" alt="contact"/> </a></div>
je n'en revient pas !
WP 2.5.1 plugins : cformII, feedsmith, getcustomfields, postthumb rev, wp-phpmyadmin, language switcher…
Hors ligne