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 13-06-2007 05:10:46
traduction de WP-PostViews
J’utilise un merveilleux petit plugin de l’auteur Lester 'GaMerZ' Chan
Cependant, après plusieurs tentatives, je me résigne à faire appelle à la communauté WP francophone pour traduire ce petit bijoux : WP-PostViews, (qui devrait ultérieurement être incorporé à WordPress par défaut),
De la sorte, je recherche simplement à traduire l’expression « views » sur la page d’entrée de mes articles par « visionnements ». Et vraiment, je ne vois pas lequel des "Views" je dois modifier dans le code du plugin tellement le mot revient souvent. Je vous laisse donc regarder par vous-même.
Code:
- <?php
- /*
- Plugin Name: WP-PostViews
- Plugin URI: http://www.lesterchan.net/portfolio/programming.php
- Description: Enables you to display how many times a post had been viewed. It will not count registered member views, but that can be changed easily.
- Version: 1.10
- Author: GaMerZ
- Author URI: http://www.lesterchan.net
- */
- /*
- Copyright 2007 Lester Chan (email : gamerz84@hotmail.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- ### Create Text Domain For Translation
- load_plugin_textdomain('wp-postviews', 'wp-content/plugins/postviews');
- ### Function: Calculate Post Views
- add_action('loop_start', 'process_postviews');
- function process_postviews() {
- global $id;
- $post_views = get_post_custom($post_id);
- $post_views = intval($post_views['views'][0]);
- if(empty($_COOKIE[USER_COOKIE])) {
- if(is_single() || is_page()) {
- if($post_views > 0) {
- update_post_meta($id, 'views', ($post_views+1));
- } else {
- add_post_meta($id, 'views', 1, true);
- }
- remove_action('loop_start', 'process_postviews');
- }
- }
- }
- ### Function: Display The Post Views
- function the_views($text_views = '', $display = true) {
- if(empty($text_views)) {
- $text_views = __('Views', 'wp-postviews');
- }
- $post_views = intval(post_custom('views'));
- if($display) {
- echo number_format($post_views).' '.$text_views;
- } else {
- return $post_views;
- }
- }
- ### Function: Display Most Viewed Page/Post
- if(!function_exists('get_most_viewed')) {
- function get_most_viewed($mode = '', $limit = 10, $chars = 0, $display = true) {
- global $wpdb, $post;
- $where = '';
- $temp = '';
- if(!empty($mode) && $mode != 'both') {
- $where = "post_type = '$mode'";
- } else {
- $where = '1=1';
- }
- $most_viewed = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
- if($most_viewed) {
- if($chars > 0) {
- foreach ($most_viewed as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $post_views = intval($post->views);
- $post_views = number_format($post_views);
- $temp .= "<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $post_views ".__('Views', 'wp-postviews')."</li>\n";
- }
- } else {
- foreach ($most_viewed as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $post_views = intval($post->views);
- $post_views = number_format($post_views);
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('Views', 'wp-postviews')."</li>\n";
- }
- }
- } else {
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
- }
- if($display) {
- echo $temp;
- } else {
- return $temp;
- }
- }
- }
- ### Function: Display Most Viewed Page/Post By Category ID
- if(!function_exists('get_most_viewed_category')) {
- function get_most_viewed_category($category_id = 0, $mode = '', $limit = 10, $chars = 0, $display = true) {
- global $wpdb, $post;
- $where = '';
- $temp = '';
- if(!empty($mode) && $mode != 'both') {
- $where = "post_type = '$mode'";
- } else {
- $where = '1=1';
- }
- $most_viewed = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID LEFT JOIN $wpdb->post2cat ON $wpdb->post2cat.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $wpdb->post2cat.category_id = $category_id AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
- if($most_viewed) {
- if($chars > 0) {
- foreach ($most_viewed as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $post_views = intval($post->views);
- $post_views = number_format($post_views);
- $temp .= "<li><a href=\"".get_permalink()."\">".snippet_chars($post_title, $chars)."</a> - $post_views ".__('Views', 'wp-postviews')."</li>\n";
- }
- } else {
- foreach ($most_viewed as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $post_views = intval($post->views);
- $post_views = number_format($post_views);
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('Views', 'wp-postviews')."</li>\n";
- }
- }
- } else {
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
- }
- if($display) {
- echo $temp;
- } else {
- return $temp;
- }
- }
- }
- ### Added by Paolo Tagliaferri (http://www.vortexmind.net - webmaster@vortexmind.net)
- function get_timespan_most_viewed($mode = '', $limit = 10, $days = 7, $display = true) {
- global $wpdb, $post;
- $limit_date = current_time('timestamp') - ($days*86400);
- $limit_date = date("Y-m-d H:i:s",$limit_date);
- $where = '';
- $temp = '';
- if(!empty($mode) && $mode != 'both') {
- $where = "post_type = '$mode'";
- } else {
- $where = '1=1';
- }
- $most_viewed = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_status, post_date, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND post_date > '".$limit_date."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
- if($most_viewed) {
- foreach ($most_viewed as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $post_views = intval($post->views);
- $post_views = number_format($post_views);
- $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - $post_views ".__('Views', 'wp-postviews')."</li>";
- }
- } else {
- $temp = '<li>'.__('N/A', 'wp-postviews').'</li>'."\n";
- }
- if($display) {
- echo $temp;
- } else {
- return $temp;
- }
- }
- ### Function: Display Total Views
- if(!function_exists('get_totalviews')) {
- function get_totalviews($display = true) {
- global $wpdb;
- $total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'views'");
- if($display) {
- echo number_format($total_views);
- } else {
- return number_format($total_views);
- }
- }
- }
- ### Function: Snippet Text
- if(!function_exists('snippet_chars')) {
- function snippet_chars($text, $length = 0) {
- $text = htmlspecialchars_decode($text);
- if (strlen($text) > $length){
- return htmlspecialchars(substr($text,0,$length)).'...';
- } else {
- return htmlspecialchars($text);
- }
- }
- }
- ### Function: HTML Special Chars Decode
- if (!function_exists('htmlspecialchars_decode')) {
- function htmlspecialchars_decode($text) {
- return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
- }
- }
- ### Function: Modify Default WordPress Listing To Make It Sorted By Post Views
- function views_join($content) {
- global $wpdb;
- $content .= " LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID";
- return $content;
- }
- function views_where($content) {
- global $wpdb;
- $content .= " AND $wpdb->postmeta.meta_key = 'views'";
- return $content;
- }
- function views_orderby($content) {
- global $wpdb;
- $content = " $wpdb->postmeta.meta_value DESC";
- return $content;
- }
- //add_filter('posts_join', 'views_join');
- //add_filter('posts_where', 'views_where');
- //add_filter('posts_orderby', 'views_orderby');
- ?>
Merci Groupe pour l'attention
Hors ligne
#2 13-06-2007 09:46:42
- dlo
- Blogodépendant

- Date d'inscription: 10-04-2007
- Messages: 1480
Re: traduction de WP-PostViews
Bonjour,
Il faut changer tous ceux qui correspondent aux chaînes de recherche suivantes:
__('Views' et _e('Views
Mais, en toute logique, vu que le plugin est "internationalisé" (cf. code suivant : ### Create Text Domain For Translation
load_plugin_textdomain('wp-postviews', 'wp-content/plugins/postviews')
, il faudrait créer un fichier .mo avec les traductions et ne pas modifier le plugin directement.
Cordialement
PS: Je traduirais 'Views' par 'A été vu x fois' plutôt que par 'visionnements'. Mais c'est un avis qui n'engage que moi... 
Dernière modification par dlo (13-06-2007 09:50:56)
Non, je ne suis pas blogodépendant... C'est juste que je n'ai toujours pas trouvé la sortie de ce forum !
Hors ligne
#3 13-06-2007 19:49:04
Re: traduction de WP-PostViews
Permettez mon ignorance... mais il y a à l'intérieur du dossier du plugin un fichier .pot
Or, à lire quelques mots dans le code, il me semble que ce fichier est lié d'une certaine façon à la traduction.
De la sorte, si c'est le cas... si je comprends bien, il suffirait de traduire ce fichier pour offrir ici ce plugin en français :

Code:
- msgid ""
- msgstr ""
- "Project-Id-Version: WP-PostViews 1.10\n"
- "POT-Creation-Date: \n"
- "PO-Revision-Date: 2007-01-30 20:31+0800\n"
- "Last-Translator: Lester 'GaMerZ' Chan <gamerz84@hotmail.com>\n"
- "Language-Team: Lester Chan <gamerz84@hotmail.com>\n"
- "MIME-Version: 1.0\n"
- "Content-Type: text/plain; charset=utf-8\n"
- "Content-Transfer-Encoding: 8bit\n"
- "X-Poedit-Language: English\n"
- "X-Poedit-Country: SINGAPORE\n"
- "X-Poedit-KeywordsList: __;_e\n"
- "X-Poedit-Basepath: .\n"
- "X-Poedit-SearchPath-0: .\n"
- #: postviews.php:57
- #: postviews.php:86
- #: postviews.php:93
- #: postviews.php:126
- #: postviews.php:133
- #: postviews.php:166
- msgid "Views"
- msgstr ""
- #: postviews.php:97
- #: postviews.php:137
- #: postviews.php:169
- msgid "N/A"
- msgstr ""
Hors ligne
#4 13-06-2007 20:18:53
Re: traduction de WP-PostViews
Utilise POedit, c'est un logiciel qui te permettra d'ouvrit le POT et de le traduire pour en faire un MO, fichier qui te traduira le plugin... attention ces fichiers doivent avoir un nom précis.
Que la Force soit avec vous...
-----------------------------------------------------------------------------
Si vous aimez la BD, vous aimerez www.kroniks.net
Hors ligne
#5 14-06-2007 02:50:32
Re: traduction de WP-PostViews
Finalement, en suivant le conseil de dlo, la traduction fut un jeu d'enfant.
Merci.
En passant Ben, POedit peut s'ouvrir dans Dreamweaver aussi.
Dernière modification par radiCarl (14-06-2007 02:50:51)
Hors ligne