Changeset 40947

Show
Ignore:
Timestamp:
04/16/08 11:59:48 (3 months ago)
Author:
ketsugi
Message:

[CHG] Internationalisation support added

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • acronyms/trunk/acronyms.php

    r40864 r40947  
    176176      } 
    177177       
     178      /* string get_textdomain () 
     179       *  
     180       * returns the text domain to be used for internationalisation 
     181       */ 
     182      function get_textdomain () 
     183      { 
     184            return "Acronyms"; 
     185      } 
     186       
    178187      /* void uninstall () 
    179188       */ 
     
    190199      function add_pages () 
    191200      { 
     201            $domain = Acronyms::get_textdomain(); 
     202             
    192203            // Add the Manage page 
    193             add_management_page( __( 'Manage Acronyms' ), __( 'Acronyms' ), "manage_options", __FILE__, array( 'Acronyms', 'manage_acronyms' ) ); 
    194       } 
    195        
     204            add_management_page( __( 'Manage Acronyms', $domain ), __( 'Acronyms', $domain ), "manage_options", __FILE__, array( 'Acronyms', 'manage_acronyms' ) ); 
     205      } 
     206       
     207      /** 
     208       * void management_handler () 
     209       * 
     210       * handles actions for adding, editing or deleting acronyms 
     211       * 
     212       */    
    196213      function management_handler () { 
    197             $title = __( 'Acronyms' ); 
     214            $domain = Acronyms::get_textdomain(); 
     215            load_plugin_textdomain( $domain, "/wp-content/plugins/your-plugin-directory/" ); 
     216             
     217            $title = __( 'Acronyms', $domain ); 
    198218            $parent_file = 'edit.php?page=' . Acronyms::get_parent_url(); 
    199219             
     
    266286      function manage_acronyms () 
    267287      { 
     288            $domain = Acronyms::get_textdomain(); 
     289             
    268290            // Set any error/notice messages based on the 'message' GET value 
    269291            $message = $_GET['message']; 
    270             $messages[1] = __('Acronym added.'); 
    271             $messages[2] = __('Acronym deleted.'); 
    272             $messages[3] = __('Acronym updated.'); 
    273             $messages[4] = __('Acronym not added.'); 
    274             $messages[5] = __('Acronym not updated.'); 
    275             $messages[6] = __('Acronyms deleted.'); 
     292            $messages[1] = __('Acronym added.', $domain ); 
     293            $messages[2] = __('Acronym deleted.', $domain ); 
     294            $messages[3] = __('Acronym updated.', $domain ); 
     295            $messages[4] = __('Acronym not added.', $domain ); 
     296            $messages[5] = __('Acronym not updated.', $domain ); 
     297            $messages[6] = __('Acronyms deleted.', $domain ); 
    276298             
    277299            if ( isset( $message ) ) { ?> 
     
    298320  <input type="hidden" name="page" value="<?php echo Acronyms::get_parent_url() ?>"/> 
    299321  <h2><?php 
    300                                    _e('Manage Acronyms'); 
    301                                    if( 'edit' != $_GET['action'] ) echo ' (<a href="#addacronym">' . __('add new') . '</a>)' 
     322            _e('Manage Acronyms', $domain ); 
     323            if( 'edit' != $_GET['action'] ) echo ' (<a href="#addacronym">' . __('add new', $domain ) . '</a>)' 
    302324            ?></h2> 
    303325      <p id="post-search"> 
    304326            <input type="text" id="post-search-input" name="search" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" /> 
    305             <input type="submit" value="<?php _e( 'Search acronyms' ); ?>" class="button" /> 
     327            <input type="submit" value="<?php _e( 'Search acronyms', $domain ); ?>" class="button" /> 
    306328      </p> 
    307329      <br class="clear" /> 
    308330<?php  
    309 Acronyms::show_pagination_bar( $n, $p, $t, $o, true); 
    310 Acronyms::show_acronym_list( $s, $n, $p, $o ); 
    311 Acronyms::show_pagination_bar( $n, $p, $t, $o); 
     331           Acronyms::show_pagination_bar( $n, $p, $t, $o, true); 
     332           Acronyms::show_acronym_list( $s, $n, $p, $o ); 
     333           Acronyms::show_pagination_bar( $n, $p, $t, $o); 
    312334?> 
    313335  </form> 
     
    359381      function show_acronym_list ( $s, $n, $p = '1', $o = 'acronym' ) 
    360382      { 
     383            $domain = Acronyms::get_textdomain(); 
     384             
    361385            // Sort the acronyms appropriately 
    362386            $acronyms = get_option( 'acronym_acronyms' ); 
     
    371395      <tr> 
    372396    <th scope="col" class="check-column"><span class="acronym-tooltip" title="<?php _e( 'Select all acronyms' , $domain ) ?>"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></span></th> 
    373     <th scope="col"><?php _e('Acronym') ?></th> 
    374     <th scope="col"><?php _e('Full') ?></th> 
     397    <th scope="col"><?php _e( 'Acronym', $domain ) ?></th> 
     398    <th scope="col"><?php _e( 'Full', $domain ) ?></th> 
    375399      </tr> 
    376400      </thead> 
     
    404428      function show_pagination_bar ( $n, $p, $t, $o, $filter = false) 
    405429      { 
     430            $domain = Acronyms::get_textdomain(); 
     431             
    406432            echo '<div class="tablenav">'; 
    407433            // Display pagination links 
     
    419445 
    420446    <div class="alignleft"> 
    421       <input type="submit" value="<?php _e('Delete') ?>" name="delete-acronyms" class="button-secondary delete" /> 
     447      <input type="submit" value="<?php _e( 'Delete' ) ?>" name="delete-acronyms" class="button-secondary delete" /> 
    422448<?php 
    423449            wp_nonce_field('delete-acronyms'); 
     
    428454                        echo '<option value="' . $option . '"'; 
    429455                        if ( $n == $option ) echo ' selected="selected" '; 
    430                         echo '>Show ' . $option . ' acronyms per page</option>'; 
     456                        echo '>' 
     457                        printf( __( "Show %d acronyms per page", $domain  ), $option ); 
     458                        echo '</option>'; 
    431459                  } 
    432460?> 
    433461                  </select> 
    434462                  <select name="o" id="o"> 
    435                         <option value="acronym"<?php echo 'acronym' == $o ? ' selected="selected"' : '' ?>>Order by acronym</option> 
    436                         <option value="full"<?php echo 'full' == $o ? ' selected="selected"' : '' ?>>Order by full text</option> 
     463                        <option value="acronym"<?php echo 'acronym' == $o ? ' selected="selected"' : '' ?>><?php _e( 'Order by acronym', $domain  ) ?></option> 
     464                        <option value="full"<?php echo 'full' == $o ? ' selected="selected"' : '' ?>><?php _e( 'Order by full text', $domain ) ?></option> 
    437465                  </select> 
    438466                  <input type="submit" value="Filter" class="button-secondary" /> 
     
    453481  function add_acronym_form ( $acronym = '', $fulltext = '' ) 
    454482      { 
     483            $domain = Acronyms::get_textdomain(); 
     484             
    455485            if ( ! empty($acronym) ) { 
    456                   $heading = __('Edit Acronym'); 
    457                   $submit_text = __('Edit Acronym'); 
     486                  $heading = __( 'Edit Acronym', $domain ); 
     487                  $submit_text = __( 'Edit Acronym', $domain ); 
    458488                  $form = '<form name="editacronym" id="editacronym" method="get" action="" class="validate">'; 
    459489                  $action = 'edit-acronym'; 
    460490                  $nonce_action = 'edit-acronym'; 
    461             } else { 
    462                   $heading = __('Add Acronym'); 
    463                   $submit_text = __('Add Acronym'); 
     491            } else {  
     492                  $heading = __( 'Add Acronym', $domain ); 
     493                  $submit_text = __( 'Add Acronym', $domain ); 
    464494                  $form = '<form name="addacronym" id="addacronym" method="get" action="" class="add:the-list: validate">'; 
    465495                  $action = 'add-acronym'; 
     
    476506      <table class="form-table"> 
    477507            <tr class="form-field form-required"> 
    478                   <td><label for="acronym"><?php _e('Acronym') ?></label>: <input name="acronym" id="acronym" type="text" value="<?php echo attribute_escape($acronym); ?>" size="20" <?php if ( 'edit-acronym' == $action ) echo 'readonly="readonly"'; ?>/></td> 
    479                   <td><label for="fulltext"><?php _e('Full') ?></label>: <input name="fulltext" id="fulltext" type="text" value="<?php echo attribute_escape($fulltext); ?>" size="80" /></td> 
     508                  <td><label for="acronym"><?php _e( 'Acronym', $domain ) ?></label>: <input name="acronym" id="acronym" type="text" value="<?php echo attribute_escape( $acronym ); ?>" size="20" <?php if ( 'edit-acronym' == $action ) echo 'readonly="readonly"'; ?>/></td> 
     509                  <td><label for="fulltext"><?php _e( 'Full', $domain ) ?></label>: <input name="fulltext" id="fulltext" type="text" value="<?php echo attribute_escape( $fulltext ); ?>" size="80" /></td> 
    480510            </tr> 
    481511      </table> 
     
    548578 
    549579add_action( 'admin_init', array( 'Acronyms', 'management_handler' ) ); 
     580register_activation_hook( __FILE__, array( 'Acronyms', 'install' ) ); 
     581register_deactivation_hook( __FILE__, array( 'Acronyms', 'uninstall' ) ); 
    550582add_action( 'admin_head', array( 'Acronyms', 'manage_acronyms_js' ) ); 
    551 register_activation_hook(__FILE__, array( 'Acronyms', 'install' ) ); 
    552 register_deactivation_hook(__FILE__, array( 'Acronyms', 'uninstall' ) ); 
    553583if (1 == get_option( 'acronym_content' ) ) 
    554584      add_filter( 'the_content', array( 'Acronyms', 'acronym_replace' ) );