Committer: ailyin
LJSUP-6154 (Developers): change it to get_remote_lang, actually return remote's language, and refactorU trunk/bin/upgrading/s2layers/core1.s2 U trunk/cgi-bin/LJ/S2.pm U trunk/cgi-bin/cleanhtml.pl U trunk/cgi-bin/ljlang.pl
Modified: trunk/bin/upgrading/s2layers/core1.s2 =================================================================== --- trunk/bin/upgrading/s2layers/core1.s2 2011-01-20 11:07:08 UTC (rev 18068) +++ trunk/bin/upgrading/s2layers/core1.s2 2011-01-20 11:07:57 UTC (rev 18069) @@ -1966,7 +1966,7 @@ return "Unknown View"; } -function builtin get_effective_lang() : string +function builtin get_remote_lang() : string "Returns remote's language"; function lang_metadata_title(string which) [fixed] : string Modified: trunk/cgi-bin/LJ/S2.pm =================================================================== --- trunk/cgi-bin/LJ/S2.pm 2011-01-20 11:07:08 UTC (rev 18068) +++ trunk/cgi-bin/LJ/S2.pm 2011-01-20 11:07:57 UTC (rev 18069) @@ -4421,9 +4421,13 @@ return join(' ', @out); } -sub get_effective_lang -{ - return LJ::Lang::get_effective_lang(); +sub get_remote_lang { + # extract a "standard" type of lang here; + # also, it's a weird way to convert en_LJ -> en + my $lang = LJ::lang_to_locale( LJ::Lang::get_remote_lang() ); + $lang =~ s/_.*//; + + return $lang; } Modified: trunk/cgi-bin/cleanhtml.pl =================================================================== --- trunk/cgi-bin/cleanhtml.pl 2011-01-20 11:07:08 UTC (rev 18068) +++ trunk/cgi-bin/cleanhtml.pl 2011-01-20 11:07:57 UTC (rev 18069) @@ -157,17 +157,7 @@ my $viewer_lang = $opts->{'viewer_lang'}; unless ($viewer_lang) { - # TODO: have some more reliable way to know that? - if (my $remote = LJ::get_remote()) { - $viewer_lang = $remote->prop('browselang') - || $LJ::DEFAULT_LANG; - } else { - if (LJ::is_web_context()) { - $viewer_lang = BML::get_language(); - } else { - $viewer_lang = $LJ::DEFAULT_LANG; - } - } + $viewer_lang = LJ::Lang::get_remote_lang(); } # cuturl or entry_url tells about context and texts address, Modified: trunk/cgi-bin/ljlang.pl =================================================================== --- trunk/cgi-bin/ljlang.pl 2011-01-20 11:07:08 UTC (rev 18068) +++ trunk/cgi-bin/ljlang.pl 2011-01-20 11:07:57 UTC (rev 18069) @@ -495,6 +495,19 @@ return $LJ::DEFAULT_LANG; } +sub get_remote_lang { + if ( my $remote = LJ::get_remote() ) { + return $remote->prop('browselang') + || $LJ::DEFAULT_LANG; + } + + if ( LJ::is_web_context() ) { + return BML::get_language(); + } + + return $LJ::DEFAULT_LANG; +} + sub ml { my ($code, $vars) = @_;