From 60e0f0426133544eaaea7ff84da5f02ca86bd8cc Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 9 Mar 2010 17:38:16 +0100 Subject: Ticket #2210: adjust locale setup fallback to try more locales on the system if en_US isn't available. We just need *something* other than C or POSIX to let gettext initialize itself, apparently... Gets Spanish, French, Russian etc UI localization working on Debian Lenny fresh installation set up in Spanish (so es_ES.UTF-8 is available but en_US.UTF-8 isn't). --- lib/util.php | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index da2799d4f..76639e2d4 100644 --- a/lib/util.php +++ b/lib/util.php @@ -52,17 +52,43 @@ function common_init_language() { mb_internal_encoding('UTF-8'); - // gettext seems very picky... We first need to setlocale() - // to a locale which _does_ exist on the system, and _then_ - // we can set in another locale that may not be set up - // (say, ga_ES for Galego/Galician) it seems to take it. - common_init_locale("en_US"); - // Note that this setlocale() call may "fail" but this is harmless; // gettext will still select the right language. $language = common_language(); $locale_set = common_init_locale($language); + if (!$locale_set) { + // The requested locale doesn't exist on the system. + // + // gettext seems very picky... We first need to setlocale() + // to a locale which _does_ exist on the system, and _then_ + // we can set in another locale that may not be set up + // (say, ga_ES for Galego/Galician) it seems to take it. + // + // For some reason C and POSIX which are guaranteed to work + // don't do the job. en_US.UTF-8 should be there most of the + // time, but not guaranteed. + $ok = common_init_locale("en_US"); + if (!$ok) { + // Try to find a complete, working locale... + // @fixme shelling out feels awfully inefficient + // but I don't think there's a more standard way. + $all = `locale -a`; + foreach (explode("\n", $all) as $locale) { + if (preg_match('/\.utf[-_]?8$/i', $locale)) { + $ok = setlocale(LC_ALL, $locale); + if ($ok) { + break; + } + } + } + if (!$ok) { + common_log(LOG_ERR, "Unable to find a UTF-8 locale on this system; UI translations may not work."); + } + } + $locale_set = common_init_locale($language); + } + setlocale(LC_CTYPE, 'C'); // So we do not have to make people install the gettext locales $path = common_config('site','locale_path'); -- cgit v1.2.3-54-g00ecf From 7f2253759ccdc5ab8698c447b29762314883db1a Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 10 Mar 2010 03:39:05 +0000 Subject: A blank username should never be allowed. --- lib/apiauth.php | 2 +- lib/util.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/apiauth.php b/lib/apiauth.php index f63c84d8f..32502399f 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -241,7 +241,7 @@ class ApiAuthAction extends ApiAction $realm = common_config('site', 'name') . ' API'; } - if (!isset($this->auth_user_nickname) && $required) { + if (empty($this->auth_user_nickname) && $required) { header('WWW-Authenticate: Basic realm="' . $realm . '"'); // show error if the user clicks 'cancel' diff --git a/lib/util.php b/lib/util.php index 76639e2d4..44ccc0def 100644 --- a/lib/util.php +++ b/lib/util.php @@ -159,6 +159,11 @@ function common_munge_password($password, $id) function common_check_user($nickname, $password) { + // empty nickname always unacceptable + if (empty($nickname)) { + return false; + } + $authenticatedUser = false; if (Event::handle('StartCheckPassword', array($nickname, $password, &$authenticatedUser))) { -- cgit v1.2.3-54-g00ecf From 8ee8b89dd8b3483724aa52a812eef89b8bfae38b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 10 Mar 2010 09:36:00 -0800 Subject: Ticket #2221: fix for missing whitespace between messages in en-gb. The final whitespace should be dropped from the source messages after we've stabilized; trailing space is pretty unreliable to keep through translation tools and should be avoided. Use separator strings outside the messages! --- lib/action.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 816086d20..9884f529c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -767,11 +767,14 @@ class Action extends HTMLOutputter // lawsuit { $this->element('dt', array('id' => 'site_statusnet_license'), _('StatusNet software license')); $this->elementStart('dd', null); + // @fixme drop the final spaces in the messages when at good spot + // to let translations get updated. if (common_config('site', 'broughtby')) { $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). '); } else { $instr = _('**%%site.name%%** is a microblogging service. '); } + $instr .= ' '; $instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION); $output = common_markup_to_html($instr); $this->raw($output); -- cgit v1.2.3-54-g00ecf