diff --git a/trunk/includes/functions.semr.php b/trunk/includes/functions.semr.php index 4636ca2..8e4347d 100644 --- a/trunk/includes/functions.semr.php +++ b/trunk/includes/functions.semr.php @@ -465,9 +465,43 @@ } } - -function semr_e($sValue, $sDomain = "semmelstatzR") { +/** + * translate and return a string + * @uses wp-function __() and prefilled plugin gettextdomain + * + * @param string $sValue string to translate + * @param string $sDomain gettextdomain + * @return string translated string + */ +function semr_i18n($sValue, $sDomain = "semmelstatzR") { return __($sValue, $sDomain); } + +/** + * translate and echo a string + * @uses wp-function _e() and prefilled plugin gettextdomain + * + * @param string $sValue + * @param string $sDomain + * @return void + */ +function semr_i18ne($sValue, $sDomain = "semmelstatzR") { + _e($sValue, $sDomain); +} + +/** + * translate and return a plural or singular string based on an amount + * @uses wp-function _n() and prefilled plugin gettextdomain + * + * @param string $sSingular + * @param string $sPlural + * @param type $iNumber + * @param string $sDomain + * @return string + */ +function semr_i18np($sSingular, $sPlural, $iNumber, $sDomain = "semmelstatzR") { + return _n($sSingular, $sPlural, $iNumber, $sDomain); +} + ############################################## Ende SEMMELSTATZ-interne Funktionen ?> \ No newline at end of file diff --git a/trunk/locale/semmelstatzR-de_DE.mo b/trunk/locale/semmelstatzR-de_DE.mo new file mode 100644 index 0000000..ba020ed Binary files /dev/null and b/trunk/locale/semmelstatzR-de_DE.mo differ diff --git a/trunk/locale/semmelstatzR-de_DE.po b/trunk/locale/semmelstatzR-de_DE.po new file mode 100644 index 0000000..8f2d193 --- /dev/null +++ b/trunk/locale/semmelstatzR-de_DE.po @@ -0,0 +1,90 @@ +msgid "" +msgstr "" +"Project-Id-Version: semmelstatzR\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-08-23 18:59+0100\n" +"PO-Revision-Date: 2011-08-23 18:59+0100\n" +"Last-Translator: Ortwin Pinke \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_c;_ngettext:1,2;_x:2c,1;semr_i18n\n" +"X-Poedit-Basepath: ../../\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Poedit-Language: German\n" +"X-Poedit-SourceCharset: utf-8\n" +"X-Poedit-Country: GERMANY\n" +"X-Poedit-SearchPath-0: semmelstatzR\n" + +#: semmelstatzR/semmelstatzR.php:96 +msgid "Current Statz" +msgstr "Aktuell" + +#: semmelstatzR/semmelstatzR.php:97 +msgid "History" +msgstr "Historie" + +#: semmelstatzR/semmelstatzR.php:98 +msgid "Log" +msgstr "Log" + +#: semmelstatzR/semmelstatzR.php:99 +msgid "Database" +msgstr "Datenbank" + +#: semmelstatzR/semmelstatzR.php:100 +msgid "Templates" +msgstr "Templates" + +#: semmelstatzR/semmelstatzR.php:101 +msgid "Options" +msgstr "Optionen" + +#: semmelstatzR/semmelstatzR.php:273 +#, php-format +msgid "%d Visitor online" +msgid_plural "%d Visitors online" +msgstr[0] "%d Besucher online" +msgstr[1] "%d Besucher online" + +#: semmelstatzR/semmelstatzR.php:275 +#, php-format +msgid "Today: %s" +msgstr "Heute: %s" + +#: semmelstatzR/semmelstatzR.php:276 +msgid "more..." +msgstr "mehr..." + +#: semmelstatzR/semmelstatzR.php:296 +msgid "Number of Items (max. 10):" +msgstr "Anzahl der Einträge (max. 20):" + +#: semmelstatzR/semmelstatzR.php:319 +msgid "... no entries" +msgstr "... keine Einträge" + +#: semmelstatzR/semmelstatzR.php:327 +#, php-format +msgid "%d Visitor" +msgid_plural "%d Visitors" +msgstr[0] "%d Besucher" +msgstr[1] "%d Besucher" + +#: semmelstatzR/semmelstatzR.php:328 +#, php-format +msgid "%d Hit" +msgid_plural "%d Hits" +msgstr[0] "%d Aufruf" +msgstr[1] "%d Aufrufe" + +#: semmelstatzR/semmelstatzR.php:329 +#, php-format +msgid "%d Referrer" +msgid_plural "%d Referrers" +msgstr[0] "%d Referer" +msgstr[1] "%d Referer" + +#~ msgid "Number of Whatever:" +#~ msgstr "Anzahl von Was auch immer:" diff --git a/trunk/semmelstatzR.css b/trunk/semmelstatzR.css index c3a8e1c..631875c 100644 --- a/trunk/semmelstatzR.css +++ b/trunk/semmelstatzR.css @@ -3,7 +3,7 @@ * * @package SemmelstatzR * @version $Rev$ - * @author Ortwin Pinke + * @author Ortwin Pinke * @author Andreas 'Redunzl' Mueller * @copyright (c)2011 PHP-Backoffice * @copyright (c)2005-2009 kopfhoch-studio diff --git a/trunk/semmelstatzR.php b/trunk/semmelstatzR.php index 6392bb1..67c0fd0 100644 --- a/trunk/semmelstatzR.php +++ b/trunk/semmelstatzR.php @@ -59,10 +59,10 @@ if(substr($_SERVER['SERVER_NAME'],0,4) == 'www.') { } ### localization -if(!load_plugin_textdomain('semmelstatzR','/wp-content/languages/')) { +//if(!load_plugin_textdomain('semmelstatzR','/wp-content/languages/')) { $plugin_dir = basename(dirname(__FILE__)); load_plugin_textdomain('semmelstatzR',null,$plugin_dir.'/locale/'); -} +//} include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr.php'; include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr_template.php'; @@ -93,12 +93,12 @@ if(is_admin() == true) { add_menu_page('SemmelstatzR','SemmelstatzR', 'manage_statz', 'semmelstatzR/semmelstatzR-statz.php', '', plugins_url('semmelstatzR/img/statz_small.png')); } if (function_exists('add_submenu_page')) { - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('Current Statz'), semr_e('Current Statz'), 'manage_statz', 'semmelstatzR/semmelstatzR-statz.php'); - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('History'), semr_e('History'), 'manage_statz', 'semmelstatzR/semmelstatzR-history.php'); - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('Log'), semr_e('Log'), 'manage_statz', 'semmelstatzR/semmelstatzR-log.php'); - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('Database'), semr_e('Database'), 'manage_statz', 'semmelstatzR/semmelstatzR-database.php'); - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('Templates'), semr_e('Templates'), 'manage_statz', 'semmelstatzR/semmelstatzR-templates.php'); - add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_e('Options'), semr_e('Options'), 'manage_statz', 'semmelstatzR/semmelstatzR-options.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('Current Statz'), semr_i18n('Current Statz'), 'manage_statz', 'semmelstatzR/semmelstatzR-statz.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('History'), semr_i18n('History'), 'manage_statz', 'semmelstatzR/semmelstatzR-history.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('Log'), semr_i18n('Log'), 'manage_statz', 'semmelstatzR/semmelstatzR-log.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('Database'), semr_i18n('Database'), 'manage_statz', 'semmelstatzR/semmelstatzR-database.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('Templates'), semr_i18n('Templates'), 'manage_statz', 'semmelstatzR/semmelstatzR-templates.php'); + add_submenu_page('semmelstatzR/semmelstatzR-statz.php', semr_i18n('Options'), semr_i18n('Options'), 'manage_statz', 'semmelstatzR/semmelstatzR-options.php'); } } add_action('admin_menu', 'semmelstatzR_menu'); @@ -151,8 +151,6 @@ if(is_admin() == true) { add_action('init', 'sem_init_options'); ### End write defaults to options-array -} else { - } @@ -288,21 +286,27 @@ function sem_dashboardStatz_control() { if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['dashboard-sem-dashboardStatz']) ) { $number = absint( $_POST['dashboard-sem-dashboardStatz']['items'] ); + $number = ($number > 20)?20:$number; $widget_options['dashboard_sem_dashboardStatz']['items'] = $number; update_option( 'dashboard_widget_options', $widget_options ); } $number = isset( $widget_options['dashboard_sem_dashboardStatz']['items'] ) ? (int) $widget_options['dashboard_sem_dashboardStatz']['items'] : ''; - echo '

'; + echo '

'; echo '

'; - print_r($widget_options['dashboard_sem_dashboardStatz']); + //print_r($widget_options['dashboard_sem_dashboardStatz']); } -### Widget für die Mini-STATZ -add_action('wp_dashboard_setup', 'sem_dashboardStatz_setup'); - +/** + * Callback generating a small dashboard widget + * + * @uses sem_showTodayStatz() to generate the content + * @uses wp_add_dashboard_widget() to generate widget + * + * @return void + */ function sem_dashboardStatz_setup() { $sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen if(!current_user_can('manage_statz')) return; @@ -310,14 +314,21 @@ function sem_dashboardStatz_setup() { wp_add_dashboard_widget( 'sem_dashboardStatz', 'SemmelstatzR', 'sem_dashboardStatz_show', 'sem_dashboardStatz_control' ); } -### Mini-Statz für Dashboard-Widget & AKTUELL-Anzeige +add_action('wp_dashboard_setup', 'sem_dashboardStatz_setup'); + +/** + * generates and returns content for a small dashboard widget + * + * @global wpdb $wpdb + * @return string formated string/html for dashboard + */ function sem_showTodayStatz() { global $wpdb; $thedays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors, COUNT(DISTINCT referer) AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE time >= CURDATE() GROUP BY date"); //$thedays = array(array('hits' => 33)); if (empty($thedays)) { - return "".__("... no entries", "semmelstatzR").""; + return "".semr_i18n("... no entries").""; } foreach($thedays as $key=>$theday) { $date = mysql2date("l",$theday->date); @@ -325,8 +336,8 @@ function sem_dashboardStatz_setup() { $visitors = $theday->visitors; $referers = $theday->referers; } - return sprintf(_n("%d Visitor","%d Visitors",$visitors, "semmelstatzR"),$visitors)." - " - .sprintf(_n("%d Hit","%d Hits",$hits, "semmelstatzR"),$hits)." - " - .sprintf(_n("%d Referrer","%d Referrers",$referer, "semmelstatzR"),$referers); + return sprintf(semr_i18np("%d Visitor","%d Visitors",$visitors),$visitors)." - " + .sprintf(semr_i18np("%d Hit","%d Hits",$hits),$hits)." - " + .sprintf(semr_i18np("%d Referer","%d Referers",$referers),$referers); } ?> \ No newline at end of file