From 160716d10b23bc1e615f969ac0cdff124347fa6b Mon Sep 17 00:00:00 2001 From: sakamocchi Date: Wed, 30 May 2012 13:52:31 +0900 Subject: [PATCH] =?utf8?q?CHANGE:=20=E3=83=AD=E3=82=B1=E3=83=BC=E3=83=AB?= =?utf8?q?=E5=90=8D=E3=81=AB=E7=BF=BB=E8=A8=B3=E3=83=A1=E3=83=83=E3=82=BB?= =?utf8?q?=E3=83=BC=E3=82=B8=E3=81=8C=E9=81=A9=E7=94=A8=E3=81=95=E3=82=8C?= =?utf8?q?=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ロケール名の一覧はAdmin::parse_localeselectoptions()と/install/index.phpにおいて表示される。 これまではlanguage tagsを援用した名前で表示されていたが 翻訳メッセージが適用されるよう修正した。 --- install/index.php | 139 ++++++++++++++++++++++++++++++++---------- nucleus/libs/AdminActions.php | 86 +++++++++++++++----------- 2 files changed, 155 insertions(+), 70 deletions(-) diff --git a/install/index.php b/install/index.php index f1d997a..16a3c06 100644 --- a/install/index.php +++ b/install/index.php @@ -90,14 +90,7 @@ else } // include translation file -if ( array_key_exists('locale', $_POST) ) $param->set_locale(); -i18n::set_current_locale($param->locale); -$translation_file = './locales/' . i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php'; -if ( !file_exists($translation_file) ) -{ - $translation_file = './locales/en_Latn_US.UTF-8.php'; -} -include($translation_file); +$param->set_locale(); do_action(); @@ -147,7 +140,6 @@ function do_action() switch ( $param->state ) { case 'locale': - $param->set_locale(); $param->set_state('mysql'); $isPostback = false; break; @@ -296,42 +288,52 @@ function show_footer() */ function show_select_locale_form() { - // get locale list - $localelist = i18n::get_available_locale_list(); - $locales = array(); - foreach ( $localelist as $locale ) { - $checkfile = './locales/' . $locale . '.' . i18n::get_current_charset() . '.php'; - $locales[] = array( $locale, (!file_exists($checkfile) ? '* ' : '') . $locale ); - } + global $param; + ?>

- Select your locale: +

-

Nucleus is installed in the selected locale, the locale of the Asterisk prefixed will be displayed in English because there is no translation of the installer file.

-

We will wait for the translator by volunteers!

-

+

+

+

@@ -1453,7 +1455,7 @@ class ParamManager // set default values $this->state = 'locale'; $this->install_mode = 'simple'; - $this->locale = 'en_Latn_US'; + $this->locale = ''; $this->mysql_host = @ini_get('mysql.default_host'); $this->blog_name = 'My Nucleus CMS'; $this->blog_shortname = 'mynucleuscms'; @@ -1510,11 +1512,82 @@ class ParamManager public function set_locale() { $this->read_parameter(array('locale')); - - if ( !in_array($this->locale, i18n::get_available_locale_list()) ) + + if ( !$this->locale ) + { + /** + * default locale select simple implementation + * + * NOTE: + * RFC2616: Hypertext Transfer Protocol -- HTTP/1.1 + * http://www.ietf.org/rfc/rfc2616.txt + * + * 14.4 Accept-Language + * + * The Accept-Language request-header field is similar to Accept, but + * restricts the set of natural languages that are preferred as a + * response to the request. Language tags are defined in section 3.10. + * + * Accept-Language = "Accept-Language" ":" + * 1#( language-range [ ";" "q" "=" qvalue ] ) + * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) + * + * Each language-range MAY be given an associated quality value which + * represents an estimate of the user's preference for the languages + * specified by that range. The quality value defaults to "q=1". For + * example, + * + * Accept-Language: da, en-gb;q=0.8, en;q=0.7 + * + * would mean: "I prefer Danish, but will accept British English and + * other types of English." A language-range matches a language-tag if + * it exactly equals the tag, or if it exactly equals a prefix of the + * tag such that the first tag character following the prefix is "-". + * The special range "*", if present in the Accept-Language field, + * matches every tag not matched by any other range present in the + * Accept-Language field. + * + * TODO: this is appropriate implement or not + */ + $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + + /* retrieve language token of language tag from first token */ + $language = ''; + if ( is_array($languages) && count($languages) > 0 ) + { + $language = preg_replace('#^([\w]+).*$#', '$1', $languages[0]); + } + + $locales = i18n::get_available_locale_list(); + foreach ( $locales as $locale ) + { + if ( i18n::strpos($locale, $language) === 0 ) + { + $this->locale = $locale; + break; + } + } + } + + /* include installer translation messages */ + $translation_file = "./locales/{$this->locale}." . i18n::get_current_charset() . '.php'; + if ( !file_exists($translation_file) ) + { + $translation_file = './locales/en_Latn_US.UTF-8.php'; + } + include($translation_file); + + /* include global translation messages */ + $translation_file = "../nucleus/locales/{$this->locale}." . i18n::get_current_charset() . '.php'; + if ( !file_exists($translation_file) ) { - $this->locale = 'en_Latn_US'; + $translation_file = './locales/en_Latn_US.UTF-8.php'; } + include($translation_file); + + i18n::set_current_locale($this->locale); + + return; } public function check_mysql_parameters() diff --git a/nucleus/libs/AdminActions.php b/nucleus/libs/AdminActions.php index 69d816a..b836217 100644 --- a/nucleus/libs/AdminActions.php +++ b/nucleus/libs/AdminActions.php @@ -3408,62 +3408,74 @@ class AdminActions extends BaseActions */ public function parse_localeselectoptions() { - global $manager; + global $CONF, $member; $locales = i18n::get_available_locale_list(); - $memid = intRequestVar('memberid'); - if ( $memid ) + /* default option */ + if ( $this->skintype == 'editmembersettings' ) { - $mem =& $manager->getMember($memid); - if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) ) - { - echo "\n"; - } - else - { - echo "\n"; - } + if ( !$member->getLocale() ) + { + echo "\n"; + } + else + { + echo "\n"; + } } else { - if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) ) - { - echo "\n"; - } - else - { - echo "\n"; - } + if ( $CONF['Locale'] == 'en_Latn_US' ) + { + echo "\n"; + } + else + { + echo "\n"; + } } + + /* optional options */ foreach ( $locales as $locale ) { - if ( $locale == 'en_Latn_US' ) + if ( $this->skintype == 'editmembersettings' ) { - continue; + if ( $locale != $member->getLocale() ) + { + echo "\n"; - } - else + if ( $locale == 'en_Latn_US' ) { - echo "\n"; + /* already output */ + continue; } + else if ( $locale != $CONF['Locale'] ) + { + echo "\n"; - } - else - { - echo "\n"; - } + echo constant($label); } + echo "\n"; } return; } -- 2.11.0