2005-04-02 15:51:45 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2005-04-02 15:51:45 +00:00
require_once ( " ../inc/util.inc " );
require_once ( " ../inc/translation.inc " );
2011-02-09 22:11:34 +00:00
check_get_args ( array ( " set_lang " ));
2013-12-04 18:22:11 +00:00
$languages = get_supported_languages ();
2009-03-24 21:24:57 +00:00
if ( ! is_array ( $languages )) {
error_page ( " Language selection not enabled. Project admins must run the update_translations.php script. " );
}
2013-05-09 05:42:43 +00:00
$prefs = " " ;
if ( isset ( $_SERVER [ " HTTP_ACCEPT_LANGUAGE " ])) {
$prefs = $_SERVER [ " HTTP_ACCEPT_LANGUAGE " ];
$prefs = sanitize_tags ( $prefs );
}
2005-04-02 15:51:45 +00:00
2005-12-06 23:00:44 +00:00
$set_lang = get_str ( " set_lang " , true );
if ( $set_lang ){
2007-04-27 16:27:12 +00:00
if ( ! in_array ( $set_lang , $languages ) && $set_lang != " auto " ){
2008-09-17 15:59:14 +00:00
error_page ( " Language not supported " );
2005-04-02 15:51:45 +00:00
} else {
2008-02-13 19:02:44 +00:00
send_cookie ( 'lang' , $set_lang , true );
2005-04-05 06:43:58 +00:00
header ( " Location: index.php " );
2005-04-02 18:37:22 +00:00
exit ;
2005-04-02 15:51:45 +00:00
}
}
2010-01-16 06:19:19 +00:00
page_head ( tra ( " Language selection " ));
2005-04-02 15:51:45 +00:00
2010-01-22 18:09:05 +00:00
function language_name ( $code ) {
if ( $code == 'en' ) {
return " <em>en</em> (English) " ;
} else {
$lname = tr_specific ( " LANG_NAME_NATIVE " , $code );
if ( $lname == 'English' || $lname == '' ) {
return " <b> $code </b> " ;
} else {
return " <b> $code </b> ( "
. tr_specific ( " LANG_NAME_INTERNATIONAL " , $code )
. " / $lname ) "
;
}
}
}
if ( count ( $languages_in_use )) {
$cur_lang_name = language_name ( $languages_in_use [ 0 ]);
} else {
$cur_lang_name = language_name ( 'en' );
}
2010-01-16 06:19:19 +00:00
echo " <p> " ,
2010-01-21 00:14:56 +00:00
tra (
2010-01-22 18:09:05 +00:00
" This web site is available in several languages. The currently selected language is %1. " ,
$cur_lang_name
2010-01-21 00:14:56 +00:00
),
2010-01-22 18:09:05 +00:00
" </p><p> " ,
2010-01-21 00:14:56 +00:00
tra (
" Normally the choice of language is determined by your browser's language setting, which is: %1. You can change this setting using: " ,
" <b> $prefs </b> "
),
2010-01-16 06:19:19 +00:00
" </p><ul> " ,
2010-01-21 00:14:56 +00:00
" <li> " ,
tra ( " Firefox: Tools/Options/General " ),
" <li> " ,
tra ( " Microsoft IE: Tools/Internet Options/Languages " ),
2010-01-16 06:19:19 +00:00
" </ul> " ,
" <p> " ,
2010-01-21 00:14:56 +00:00
tra (
" Or you can select a language by clicking on one of the links. This will send your browser a cookie; make sure your browser accepts cookies from our domain. "
),
2010-01-16 06:19:19 +00:00
" </p> "
;
2005-04-02 15:51:45 +00:00
start_table ();
2010-01-22 18:09:05 +00:00
row1 ( tra ( " Language name (click to select) " ));
row1 ( " <a href=language_select.php?set_lang=auto> "
. tra ( " Use browser language setting " )
. " </a> " ,
1 , " row1 "
2005-12-06 23:00:44 +00:00
);
2008-10-12 15:22:16 +00:00
sort ( $languages );
2010-01-22 18:09:05 +00:00
$i = 0 ;
2008-10-30 18:27:22 +00:00
foreach ( $languages as $language ) {
2010-01-22 18:09:05 +00:00
$name = language_name ( $language );
row1 (
" <a href= \" language_select.php?set_lang= $language\ " > $name </ a > " ,
1 , " row $i "
2005-04-02 18:37:22 +00:00
);
2010-01-22 18:09:05 +00:00
$i = 1 - $i ;
2005-04-02 15:51:45 +00:00
}
end_table ();
2010-01-16 06:19:19 +00:00
echo " <p> " ,
2010-01-16 23:52:05 +00:00
tra ( " Translations are done by volunteers. If your native language is not here, %1you can provide a translation%2. " ,
2010-01-16 06:19:19 +00:00
'<a href="http://boinc.berkeley.edu/trac/wiki/TranslateIntro">' , '</a>' ),
" </p> "
;
2005-04-02 15:51:45 +00:00
page_tail ();
?>