Autor Zpráva
rosomák
Profil
Ahoj,
v PHP jsem lama, takže se na vás zde obracím s prosbou jak počeštit plugin ve WordPressu. Jde mi jen o to ho počeštit v tom, aby na stránce s příspěvky (web je zde vypisoval místo view např. zobrazeno.

Kód pluginu:

<?php

/*
Plugin Name: WP-PostViews
Plugin URI: http://lesterchan.net/portfolio/programming/php/
Description: Enables you to display how many times a post/page had been viewed. Modified by <a href="http://DPotter.net/Technical/" title="David's Technical Musings">David Potter</a> to include options for when and where to display view counts.
Version: 1.60
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
*/


/*
Copyright 2009 Lester Chan (email : lesterchan@gmail.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
*/


### Load WP-Config File If This File Is Called Directly
if (!function_exists('add_action')) {
$wp_root = '../../..';
if (file_exists($wp_root.'/wp-load.php')) {
require_once($wp_root.'/wp-load.php');
} else {
require_once($wp_root.'/wp-config.php');
}
}


### Create Text Domain For Translations
add_action('init', 'postviews_textdomain');
function postviews_textdomain() {
load_plugin_textdomain('wp-postviews', false, 'wp-postviews');
}


### Function: Post Views Option Menu
add_action('admin_menu', 'postviews_menu');
function postviews_menu() {
if (function_exists('add_options_page')) {
add_options_page(__('PostViews', 'wp-postviews'), __('PostViews', 'wp-postviews'), 'manage_options', 'wp-postviews/postviews-options.php') ;
}
}


### Function: Calculate Post Views
add_action('wp_head', 'process_postviews');
function process_postviews() {
global $user_ID, $post;
if(is_int($post)) {
$post = get_post($post);
}
if(!wp_is_post_revision($post)) {
if(is_single() || is_page()) {
$id = intval($post->ID);
$views_options = get_option('views_options');
$post_views = get_post_custom($id);
$post_views = intval($post_views['views'][0]);
$should_count = false;
switch(intval($views_options['count'])) {
case 0:
$should_count = true;
break;
case 1:
if(empty($_COOKIE[USER_COOKIE]) && intval($user_ID) == 0) {
$should_count = true;
}
break;
case 2:
if(intval($user_ID) > 0) {
$should_count = true;
}
break;
}
if(intval($views_options['exclude_bots']) == 1) {
$bots = array('Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'pubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com' => 'become.com');
$useragent = $_SERVER['HTTP_USER_AGENT'];
foreach ($bots as $name => $lookfor) {
if (stristr($useragent, $lookfor) !== false) {
$should_count = false;
break;
}
}
}
if($should_count) {
if(defined('WP_CACHE') && WP_CACHE) {
echo "\n".'<!-- Start Of Script Generated By WP-PostViews 1.60 -->'."\n";
wp_print_scripts('jquery');
echo '<script type="text/javascript">'."\n";
echo '/* <![CDATA[ */'."\n";
echo "jQuery.ajax({type:'GET',url:'".plugins_url('wp-postviews/wp-postviews.php')."',data:'postviews_id=".$id."',cache:false});";
echo '/* ]]> */'."\n";
echo '</script>'."\n";
echo '<!-- End Of Script Generated By WP-PostViews 1.60 -->'."\n";
} else {
if(!update_post_meta($id, 'views', ($post_views+1))) {
add_post_meta($id, 'views', 1, true);
}
}
}
}
}
}


### Function: Determine If Post Views Should Be Displayed (By: David Potter)
function should_views_be_displayed($views_options = null) {
if ($views_options == null) {
$views_options = get_option('views_options');
}
$display_option = 0;
if (is_home()) {
if (array_key_exists('display_home', $views_options)) {
$display_option = $views_options['display_home'];
}
} elseif (is_single()) {
if (array_key_exists('display_single', $views_options)) {
$display_option = $views_options['display_single'];
}
} elseif (is_page()) {
if (array_key_exists('display_page', $views_options)) {
$display_option = $views_options['display_page'];
}
} elseif (is_archive()) {
if (array_key_exists('display_archive', $views_options)) {
$display_option = $views_options['display_archive'];
}
} elseif (is_search()) {
if (array_key_exists('display_search', $views_options)) {
$display_option = $views_options['display_search'];
}
} else {
if (array_key_exists('display_other', $views_options)) {
$display_option = $views_options['display_other'];
}
}
return (($display_option == 0) || (($display_option == 1) && is_user_logged_in()));
}


### Function: Display The Post Views
function the_views($display = true, $prefix = '', $postfix = '', $always = false) {
$post_views = intval(post_custom('views'));
$views_options = get_option('views_options');
if ($always || should_views_be_displayed($views_options)) {
$output = $prefix.str_replace('%VIEW_COUNT%', number_format_i18n($post_views), $views_options['template']).$postfix;
if($display) {
echo apply_filters('the_views', $output);
} else {
return apply_filters('the_views', $output);
}
}
elseif (!$display) {
return '';
}
}


### Function: Display Least Viewed Page/Post
if(!function_exists('get_least_viewed')) {
function get_least_viewed($mode = '', $limit = 10, $chars = 0, $display = true) {
global $wpdb;
$views_options = get_option('views_options');
$where = '';
$temp = '';
$output = '';
if(!empty($mode) && $mode != 'both') {
$where = "post_type = '$mode'";
} else {
$where = '1=1';
}
$most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (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 ASC LIMIT $limit");
if($most_viewed) {
foreach ($most_viewed as $post) {
$post_views = intval($post->views);
$post_title = get_the_title($post);
if($chars > 0) {
$post_title = snippet_text($post_title, $chars);
}
$post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
$temp = stripslashes($views_options['most_viewed_template']);
$temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp);
$temp = str_repla
Stano
Profil *
no v skratke:
najdi si v plugine súbor process_postviews-en_EN.po stiahni si program Poedit načitaj si ten súbor do Poedit prelož a vygeneruj process_postviews-cs_CZ.mo a nahraj oba súbory do toho priečinku kde si našiel pôvodny súbor.

ak tam taky subor nieje kontaktuj autora pluginu.

druha možnosť je hľadať v kóde funkcie __("","") napr __('PostViews', 'wp-postviews') a prepísať to na __('Prehľad článkov', 'wp-postviews'). Toto riešenie moc neodporúčam, lebo vždy ked si updatneš tento plugin tak to budeš musieť prepisovať nanovo.

podrobný návod na preklad pluginov je tu http://codex.wordpress.org/Translating_WordPress
rosomák
Profil
Aha, já myslel, že v kódu půjde přepsat jen jedno view na zobrazeno a bude to hotové :-(

edit:
jinak ve složce s pluginem (wp-postviews) mám pouze: wp-postviews.php, postviews-options.php a readme.txt. Žádný jazykový soubor tam není.
Stano
Profil *
No svojim spôsobom ak sa jedná len o jedno slovo tak to stačí. nájdi si niekde v kode __('view', 'wp-postviews') a prepíš na __('zobrazeno', 'wp-postviews')
Stano
Profil *
máš to na 680 riadku v wp-postviews.php
rosomák
Profil
$this->WP_Widget('zobrazeno', __('Zobrazeno', 'wp-postviews'), $widget_ops);

Takto jsem to přepsal, ale nejede to :-(
Stano
Profil *
dalsie mas na 730 a 803 a tamto si este prepisal aj zle. prepisuj len to co je v zatvorke za __(

$this->WP_Widget('views', __('Zobrazeno', 'wp-postviews'), $widget_ops);

ak prepises aj dalsie dva tak by to hadam malo ist.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: