Chaînes personnalisées pour la traduction à l'aide du plugin Polylang
-
-
Cette questionne répondpastrèsbien dans saforme actuelle.Lafaçon dont vous aborderiez latraduction de ces chaînes abeaucoup à voir avec lafaçon dont vospluginset votrethème sont écritset est un sujetimportant.This question isn't very answerable in its current form. How you'd address translating those strings has a lot to do with how your plugins and theme are written and is a big topic.
- 0
- 2013-01-23
- s_ha_dum
-
Commentpuis-jeposer une question concrète?How can I concrete question?
- 0
- 2013-01-27
- tro
-
2 réponses
- votes
-
- 2013-02-13
Utilisez ceci
pll_register_string ()
surfunctions.php
Utilisez-le comme ceci:
pll_register_string Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes). Usage: pll_register_string($name, $string, $multiline); ‘$name’ => (required) name provided for sorting convenience (ex: ‘myplugin’) ‘$string’ => (required) the string to translate ‘$multiline’ => (optional) if set to true, the translation text field will be multiline, defaults to false
Donc:
pll_register_string ('Titre de l'en-tête','Letitre que vous voulez voir apparaître');
Ensuite,sur la configuration dutableau debord,sur les langues,vous alleztrouver un robinet appelé "chaînes". Là,vous allez avoir cettenouvelle chaîne crééeet untexte d'entréepour remplir letexte detraductionpour chaque langue active sur votre site. Rédigez destraductions,puis utilisez lesfonctions:
pll_e ()pourfaire un écho directement,oupll __ ()pour l'échomanuellement. Vous allez l'utiliser comme:
pll_e('The title you want to appear'); or echo pll__('The title you want to appear');
C'esttout! :)
Use this
pll_register_string()
on functions.php
Use it like this:
pll_register_string Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes). Usage: pll_register_string($name, $string, $multiline); ‘$name’ => (required) name provided for sorting convenience (ex: ‘myplugin’) ‘$string’ => (required) the string to translate ‘$multiline’ => (optional) if set to true, the translation text field will be multiline, defaults to false
So:
pll_register_string('Header Title', 'The title you want to appear');
Then on dashboard config, on languages, you are going to find a tap called "strings". There you're going to have this new created string, and an input text to fill the translation text for every active language on your site. Write translations, and then use the funcions:
pll_e() to directly echo, or pll__() to manually echo it. Your'ge going to use it like:
pll_e('The title you want to appear'); or echo pll__('The title you want to appear');
That's it! :)
-
Merci!C'était unproblème!Étrange,cette questionest simple,maispersonnen'a répondupendant longtemps.Thanx! That was issue! Strange, that question is simple, but no one answered for a long time.
- 0
- 2013-02-14
- tro
-
«Pll»ne devrait-ilpas appeler lenom de la variableplutôt que son contenu?-> `pll_e ('Titre de l'en-tête');`?Shouldn't `pll` call the variable name, rather than its content? -> `pll_e('Header Title');` ?
- 0
- 2018-07-20
- jj_
-
- 2016-12-08
J'ai unproblème avectroyane. Ilexiste quelquesfonctions d'échappementintégrées auxfonctions d'internationalisation,telles que:esc_html __ ()et esc_html_e ()pour obtenir les chaînes d'échappement. Mais commentpuis-jefaire cela lorsquej'utiliseploylang?
Échappement des chaînes
<a title="<?php esc_attr_e( 'Skip to content', 'my-theme' ); ?>" class="screen-reader-text skip-link" href="#content" > <?php _e( 'Skip to content', 'my-theme' ); ?>
Voicimon code
<?php if (get_theme_mod('col_heading','') != '') { ?> <h2 class="section-heading"><?php esc_html_e(get_theme_mod('col_heading')); ?></h2> <?php } else { ?> <h2 class="section-heading">Services</h2> <?php } ?> <?php if (get_theme_mod('col_sub','') != '') { ?> <h3 class="section-subheading text-muted"><?php echo esc_html(get_theme_mod('col_sub','')); ?></h3> <?php } else { ?> <h3 class="section-subheading text-muted">Phasellus elementum odio faucibus diam sollicitudin</h3> <?php } ?>
I have the some problem with troyane. There are a few escape functions that are integrated with internationalization functions,Such as :esc_html__() and esc_html_e() to get the Escaping strings. But how can I do that when I use ploylang?
Escaping strings
<a title="<?php esc_attr_e( 'Skip to content', 'my-theme' ); ?>" class="screen-reader-text skip-link" href="#content" > <?php _e( 'Skip to content', 'my-theme' ); ?>
Here is my code
<?php if (get_theme_mod('col_heading','') != '') { ?> <h2 class="section-heading"><?php esc_html_e(get_theme_mod('col_heading')); ?></h2> <?php } else { ?> <h2 class="section-heading">Services</h2> <?php } ?> <?php if (get_theme_mod('col_sub','') != '') { ?> <h3 class="section-subheading text-muted"><?php echo esc_html(get_theme_mod('col_sub','')); ?></h3> <?php } else { ?> <h3 class="section-subheading text-muted">Phasellus elementum odio faucibus diam sollicitudin</h3> <?php } ?>
J'utilise leplugin WP 3.5 et Polylang 0.9.8 pourfaire destraductions dans différentes langues.
Tout vabien et lepluginfonctionnebien,maismaintenantje suis confronté à unproblème - J'aibesoin detraduire des chaînespersonnalisées ,parexemple des chaînes à l'intérieur de widgets.
Quepouvez-vousme recommanderpour résoudre ceproblème?
AJOUTÉ: Parexemple (jeparle detexte dans les widgets,maispas d'en-tête),puis-je ajouter des constantes de chaîne oupluset les écrire àpartir du codephp dansmapage -et lesfairetraduire sur lapage detraduction de chaînes de Polylang?