traduction de WP-PostViews (Créer un compte)

  • Statut : non résolu
8 sujets de 1 à 8 (sur un total de 8)
  • Auteur
    Messages
  • #452563
    radiCarl
    Membre
    Chevalier WordPress
    137 contributions

    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.

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

    #602699
    dlo
    Participant
    Maître WordPress
    1848 contributions

    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… 😋

    #602700
    radiCarl
    Membre
    Chevalier WordPress
    137 contributions

    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 :
    :D

    msgid «  »
    msgstr «  »
    « Project-Id-Version: WP-PostViews 1.10n »
    « POT-Creation-Date: n »
    « PO-Revision-Date: 2007-01-30 20:31+0800n »
    « Last-Translator: Lester ‘GaMerZ’ Chan n »
    « Language-Team: Lester Chan n »
    « MIME-Version: 1.0n »
    « Content-Type: text/plain; charset=utf-8n »
    « Content-Transfer-Encoding: 8bitn »
    « X-Poedit-Language: Englishn »
    « X-Poedit-Country: SINGAPOREn »
    « X-Poedit-KeywordsList: __;_en »
    « 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 «  »

    #602701
    benkenobi
    Participant
    Maître WordPress
    4068 contributions

    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.

    #602702
    radiCarl
    Membre
    Chevalier WordPress
    137 contributions

    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.

    #602703
    articledin
    Participant
    Initié WordPress
    3 contributions

    bonjour
    j ai les wp-postviews-fr_FR.mo et wp-postviews-fr_FR.po ( la tradution ) que dois je faire apres ?
    merci d avance

    #602704
    TradPress.fr
    Membre
    Initié WordPress
    41 contributions

    Les installer dans le répertoire i18n de l’extension. 😉

    #602705
    articledin
    Participant
    Initié WordPress
    3 contributions

    bonjour
    il n y a aucun repertoire dans le plug in wp-postviews!!!

8 sujets de 1 à 8 (sur un total de 8)
  • Vous devez être connecté pour répondre à ce sujet.