Annonce

Important, migration recommandée : WordPress 2.6.3 est disponible en français.À lire avant la migration !
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

  1. if( $langswitch_lang_pref == 'ru' ) {
  2.    // do something if the language is Russian
  3. } else {
  4.    // do something different if the language is not Russian
  5. }

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

  1. <body  onload="preloadImages()">
  2.  
  3.  
  4.     <div id="menu">
  5.        
  6.        
  7.     <?php if( $langswitch_lang_pref == 'fr' ) {?>
  8.     <a href="?cat=15"
  9.     onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  10.     onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02.gif'); return true;"
  11.     onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  12.     onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
  13.     <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>
  14.  
  15.     <?php } else { ?>
  16.     <a href="?cat=15"
  17.     onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  18.     onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02_en.gif'); return true;"
  19.     onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  20.     onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
  21.     <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>
  22.     <?php } ?>
  23.    
  24.     <a href="?page_id=12"
  25.     onmouseover="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
  26.     onmouseout="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04.gif'); return true;"
  27.     onmousedown="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
  28.     onmouseup="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;">
  29.     <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>
  30.    
  31.     <a href="/wp/?page_id=15"
  32.     onmouseover="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
  33.     onmouseout="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06.gif'); return true;"
  34.     onmousedown="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
  35.     onmouseup="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;">
  36.     <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

Xavier
Photogénique en noir et blanc
Lieu: Paris
Date d'inscription: 19-09-2005
Messages: 1737
Site web

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:

  1. <?php
  2. global $langswitch_lang_pref;
  3. if( $langswitch_lang_pref == 'fr' ) {?>

Mais globalement, je ne vois pas la différence entre tes deux code (avant le ELSE et après).


Mainteneur de la traduction de WordPress
http://xavier.borderie.net/wp-fr/

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

  1.   <div id="container">
  2.   <div id="nav">
  3.   <img id="ag_2_01.gif" src="/wp/wp-content/themes/simple/images/ag_2_01.gif" alt="alexis godefroy, design graphique"/>
  4.  
  5.     <div id="menu">
  6.        
  7.     <?php global $langswitch_lang_pref;
  8.     if( $langswitch_lang_pref == 'fr' ) { ?>
  9.     <a href="?cat=15"
  10.     onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  11.     onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02.gif'); return true;"
  12.     onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  13.     onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
  14.     <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>
  15.  
  16.     <?php } else { ?>
  17.     <a href="?cat=15"
  18.     onmouseover="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  19.     onmouseout="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02_en.gif'); return true;"
  20.     onmousedown="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;"
  21.     onmouseup="changeImages('ag_2_02', '/wp/wp-content/themes/simple/images/ag_2_02-over.gif'); return true;">
  22.     <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>
  23.     <?php } ?>
  24.    
  25.     <a href="?page_id=12"
  26.     onmouseover="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
  27.     onmouseout="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04.gif'); return true;"
  28.     onmousedown="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;"
  29.     onmouseup="changeImages('ag_2_04', '/wp/wp-content/themes/simple/images/ag_2_04-over.gif'); return true;">
  30.     <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>
  31.    
  32.     <a href="/wp/?page_id=15"
  33.     onmouseover="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
  34.     onmouseout="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06.gif'); return true;"
  35.     onmousedown="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;"
  36.     onmouseup="changeImages('ag_2_06', '/wp/wp-content/themes/simple/images/ag_2_06-over.gif'); return true;">
  37.     <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

 

Pied de page des forums

Propulsé par PunBB 1.2.20
© Copyright 2005-2006 WordPress France