Plugin Directory

Changeset 498454


Ignore:
Timestamp:
02/01/2012 10:53:18 AM (14 years ago)
Author:
gschmid
Message:

prepared for localization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zeitansage/trunk/zeitansage.php

    r497828 r498454  
    33 * Plugin Name:     Zeitansage
    44 * Plugin URI:      http://www.gunnar-schmid.de/zeitansage
    5  * Description:     A widget to display the current time as verbal expression. Currently available in German only.
     5 * Description:     A widget to display the current time as verbal expression.
    66 * Author:          Gunnar Schmid
    7  * Version:         0.1.0
     7 * Version:         0.2.0
    88 * Author URI:      http://www.gunnar-schmid.de
    99 * License:         GPLv2
     
    1111
    1212add_action( 'widgets_init', 'pbr_load_widget' );
     13$plugin_dir = basename( dirname( __FILE__) );
     14load_plugin_textdomain( 'zeitansage', null, $plugin_dir );
    1315
    1416function pbr_load_widget() {
     
    3133        echo '  <input class="widefat" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . esc_attr($title) . '" />';
    3234        echo '</p>';
    33        
    34 /*  language selection to come
    35         echo '<p>';
    36         echo '  <label for="' . $this->get_field_id( 'language' ) . '" >' . __( 'Language:' ) . '</label>';
    37         echo '  <select class="widefat" id="' . $this->get_field_id( 'language' ) . '" name="' . $this->get_field_name( 'language' ) . '">';
    38         echo '      <option ' . selected( $instance['language'], 'EN' ) . ' value="EN" >' . __( 'English' ) . '</option>';
    39         echo '      <option ' . selected( $instance['language'], 'DE' ) . ' value="DE" >' . __( 'German' ) . '</option>';
    40         echo '  </select>';
    41         echo '</p>';
    42 */     
    4335    }
    4436
     
    4739        $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '') );
    4840        $instance['title'] = strip_tags( $new_instance['title'] );
    49 /*     
    50         if ( in_array( $new_instance['language'], array( 'EN', 'DE' ) ) ) {
    51             $instance['language'] = $new_instance['language'];
    52         } else {
    53             $instance['language'] = 'EN';
    54         }
    55 */
    5641        return $instance;
    5742    }
     
    8065        $minute = round( $minute / 5 ) * 5;
    8166       
    82         // round up to next hour - CAUTION WHEN TRANSLATING: this works probably differently in other languages
    83         if ( $minute >= 25 ) {
     67        // round up to next hour
     68       
     69        // TEMP: this should go into translations somehow
     70        $roundup_to_next_hour = 35;
     71        if ( substr( get_locale(), 0, 2 ) == 'de' ) {
     72            $roundup_to_next_hour = 25;
     73        }
     74       
     75        if ( $minute >= $roundup_to_next_hour ) {
    8476            $hour++;
    8577        }
     
    9183       
    9284        return sprintf( __( 'Es ist %1$s %2$s%3$s.' ), $minute_text, $hour_text, $oclock_text );
    93         //return 'Es ist jetzt ' . $minute_text . ' ' . $hour_text . $oclock_text . '.';
    9485    }
    9586   
     
    136127            case 0:
    137128            case 60:
    138                 return __( '' );
     129                return ''; // note: no I18N for the empty string
    139130            case 5:
    140131                return __( 'fünf nach');
Note: See TracChangeset for help on using the changeset viewer.