Changeset 22049


Ignore:
Timestamp:
2012/10/02 08:57:27 (12 years ago)
Author:
pineray
Message:

#163 テキスト出力多言語対応

引数のデフォルト値を定数から変更.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-multilang/data/class/helper/SC_Helper_Locale.php

    r22045 r22049  
    4747     * @return  string  a string corresponding with message alias 
    4848     */ 
    49     function get_locale($string, $lang_code = LANG_CODE, $device_type_id = FALSE) { 
     49    function get_locale($string, $lang_code = FALSE, $device_type_id = FALSE) { 
     50        // Set language code when it is not set. 
     51        if ($lang_code === FALSE) { 
     52            $lang_code = LANG_CODE; 
     53        } 
    5054        // Get string list of specified language. 
    5155        $translations = $this->get_translations($lang_code, $device_type_id); 
     
    6670     * @return  array   strings 
    6771     */ 
    68     function get_translations($lang_code = LANG_CODE, $device_type_id = FALSE) { 
     72    function get_translations($lang_code, $device_type_id = FALSE) { 
    6973        $translations_key = "translations_" . $lang_code . "_" . $device_type_id; 
    7074        // If the strings of specified language is not loaded 
     
    97101     * @return  array   file list 
    98102     */ 
    99     function get_locale_file_list($lang_code = LANG_CODE, $device_type_id = FALSE) { 
     103    function get_locale_file_list($lang_code, $device_type_id = FALSE) { 
    100104        $file_list = array(); 
    101105 
     
    108112 
    109113        // Get a list of enabled plugins. 
    110         $arrPluginDataList = SC_Plugin_Util_Ex::getEnablePlugin(); 
    111         // Get the plugins directory. 
    112         $arrPluginDirectory = SC_Plugin_Util_Ex::getPluginDirectory(); 
    113         foreach ($arrPluginDataList as $arrPluginData) { 
    114             // Check that the plugin filename is contained in the list of plugins directory. 
    115             if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) { 
    116                 // Path to the plugin locale file. 
    117                 $plugin_locale_path = PLUGIN_UPLOAD_REALDIR . $arrPluginData['plugin_code'] . "/locales/{$lang_code}.mo"; 
    118                 // If a locale file of specified language is exist, add to the file list. 
    119                 if (file_exists($plugin_locale_path)) { 
    120                     $file_list[] = $plugin_locale_path; 
     114        if (defined(PLUGIN_UPLOAD_REALDIR)) { 
     115            $arrPluginDataList = SC_Plugin_Util_Ex::getEnablePlugin(); 
     116            // Get the plugins directory. 
     117            $arrPluginDirectory = SC_Plugin_Util_Ex::getPluginDirectory(); 
     118            foreach ($arrPluginDataList as $arrPluginData) { 
     119                // Check that the plugin filename is contained in the list of plugins directory. 
     120                if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) { 
     121                    // Path to the plugin locale file. 
     122                    $plugin_locale_path = PLUGIN_UPLOAD_REALDIR . $arrPluginData['plugin_code'] . "/locales/{$lang_code}.mo"; 
     123                    // If a locale file of specified language is exist, add to the file list. 
     124                    if (file_exists($plugin_locale_path)) { 
     125                        $file_list[] = $plugin_locale_path; 
     126                    } 
    121127                } 
    122128            } 
     
    142148     * @return integer  index 
    143149     */ 
    144     function get_plural_index($count, $lang_code = LANG_CODE) { 
     150    function get_plural_index($count, $lang_code = FALSE) { 
     151        // Set language code when it is not set. 
     152        if ($lang_code === FALSE) { 
     153            $lang_code = LANG_CODE; 
     154        } 
    145155        // Get a formula 
    146156        $string = $this->get_plural_forms($lang_code); 
     
    164174     * @return  string  formula 
    165175     */ 
    166     function get_plural_forms($lang_code = LANG_CODE) { 
     176    function get_plural_forms($lang_code) { 
    167177        // If formula is empty, include the file. 
    168178        if(empty($this->_plural_forms)){ 
Note: See TracChangeset for help on using the changeset viewer.