Annonce

Faites la différence entre le service WordPress.com et l'application libre WordPress.

Mettez-vous à jour ! WordPress 3.3.2 est disponible en français.

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.
Annonce 4 : Rejoignez-nous sur Facebook, Google + et sur Twitter

#1 30-06-2008 17:14:49

nlex
Bavard WP
Date d'inscription: 14-02-2007
Messages: 300

[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.7.1 plugins : cformII, getcustomfields, postthumb revisited, wp-phpmyadmin, language switcher, BackUpWordPress, Google XML Sitemaps, Phpinfo, Organizer, WordPress Database Backup, WP-Cats…

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: 2385
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: html

<?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).


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

Hors ligne

 

#3 30-06-2008 18:26:24

nlex
Bavard WP
Date d'inscription: 14-02-2007
Messages: 300

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">
				
		<?php global $langswitch_lang_pref;
		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.7.1 plugins : cformII, getcustomfields, postthumb revisited, wp-phpmyadmin, language switcher, BackUpWordPress, Google XML Sitemaps, Phpinfo, Organizer, WordPress Database Backup, WP-Cats…

Hors ligne

 

Pied de page des forums

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

[ Generated in 0.023 seconds, 10 queries executed ]