Browse Source

added support for internationalization

pull/7/head
Martin Monperrus 12 years ago
parent
commit
8bfbe0e0d9
  1. 51
      bibtexbrowser.php

51
bibtexbrowser.php

@ -331,6 +331,14 @@ function _zetDB($bibtex_filenames) {
return array(&$db, $parse, $updated, $saved); return array(&$db, $parse, $updated, $saved);
} // end function setDB } // end function setDB
// internationalization
function __($msg) {
global $BIBTEXBROWSER_LANG;
if (isset($BIBTEXBROWSER_LANG[$msg])) {
return $BIBTEXBROWSER_LANG[$msg];
}
return $msg;
}
// factories // factories
// may be overridden in bibtexbrowser.local.php // may be overridden in bibtexbrowser.local.php
@ -1427,7 +1435,7 @@ class BibEntry {
$url_parts[]='rft_id='.s3988('info:doi/'.$this->getField("doi")); $url_parts[]='rft_id='.s3988('info:doi/'.$this->getField("doi"));
} }
// referrer, the id pf a collection of objects
// referrer, the id of a collection of objects
// see also http://www.openurl.info/registry/docs/pdf/info-sid.pdf // see also http://www.openurl.info/registry/docs/pdf/info-sid.pdf
$url_parts[]='rfr_id='.s3988('info:sid/'.@$_SERVER['HTTP_HOST'].':'.@$_GET[Q_FILE]); $url_parts[]='rfr_id='.s3988('info:sid/'.@$_SERVER['HTTP_HOST'].':'.@$_GET[Q_FILE]);
@ -1644,32 +1652,32 @@ return
// Books // Books
array( array(
'query' => array(Q_TYPE=>'book|proceedings'), 'query' => array(Q_TYPE=>'book|proceedings'),
'title' => 'Books'
'title' => __('Books')
), ),
// Book chapters // Book chapters
array( array(
'query' => array(Q_TYPE=>'incollection|inbook'), 'query' => array(Q_TYPE=>'incollection|inbook'),
'title' => 'Book Chapters'
'title' => __('Book Chapters')
), ),
// Journal / Bookchapters // Journal / Bookchapters
array( array(
'query' => array(Q_TYPE=>'article'), 'query' => array(Q_TYPE=>'article'),
'title' => 'Refereed Articles'
'title' => __('Refereed Articles')
), ),
// conference papers // conference papers
array( array(
'query' => array(Q_TYPE=>'inproceedings|conference',Q_EXCLUDE=>'workshop'), 'query' => array(Q_TYPE=>'inproceedings|conference',Q_EXCLUDE=>'workshop'),
'title' => 'Refereed Conference Papers'
'title' => __('Refereed Conference Papers')
), ),
// workshop papers // workshop papers
array( array(
'query' => array(Q_TYPE=>'inproceedings',Q_SEARCH=>'workshop'), 'query' => array(Q_TYPE=>'inproceedings',Q_SEARCH=>'workshop'),
'title' => 'Refereed Workshop Papers'
'title' => __('Refereed Workshop Papers')
), ),
// misc and thesis // misc and thesis
array( array(
'query' => array(Q_TYPE=>'misc|phdthesis|mastersthesis|bachelorsthesis|techreport'), 'query' => array(Q_TYPE=>'misc|phdthesis|mastersthesis|bachelorsthesis|techreport'),
'title' => 'Other Publications'
'title' => __('Other Publications')
) )
); );
} }
@ -1707,13 +1715,13 @@ function DefaultBibliographyStyle(&$bibentry) {
// now the book title // now the book title
$booktitle = ''; $booktitle = '';
if ($type=="inproceedings") { if ($type=="inproceedings") {
$booktitle = 'In '.$bibentry->getField(BOOKTITLE); }
$booktitle = __('In').' '.$bibentry->getField(BOOKTITLE); }
if ($type=="incollection") { if ($type=="incollection") {
$booktitle = 'Chapter in '.$bibentry->getField(BOOKTITLE);}
$booktitle = __('Chapter in').' '.$bibentry->getField(BOOKTITLE);}
if ($type=="inbook") { if ($type=="inbook") {
$booktitle = 'Chapter in '.$bibentry->getField('chapter');}
$booktitle = __('Chapter in').' '.$bibentry->getField('chapter');}
if ($type=="article") { if ($type=="article") {
$booktitle = 'In '.$bibentry->getField("journal");}
$booktitle = __('In').' '.$bibentry->getField("journal");}
//// we may add the editor names to the booktitle //// we may add the editor names to the booktitle
$editor=''; $editor='';
@ -1731,16 +1739,16 @@ function DefaultBibliographyStyle(&$bibentry) {
$publisher=''; $publisher='';
if ($type=="phdthesis") { if ($type=="phdthesis") {
$publisher = 'PhD thesis, '.$bibentry->getField(SCHOOL);
$publisher = __('PhD thesis').', '.$bibentry->getField(SCHOOL);
} }
if ($type=="mastersthesis") { if ($type=="mastersthesis") {
$publisher = 'Master\'s thesis, '.$bibentry->getField(SCHOOL);
$publisher = __('Master\'s thesis').', '.$bibentry->getField(SCHOOL);
} }
if ($type=="bachelorsthesis") { if ($type=="bachelorsthesis") {
$publisher = 'Bachelor\'s thesis, '.$bibentry->getField(SCHOOL);
$publisher = __('Bachelor\'s thesis').', '.$bibentry->getField(SCHOOL);
} }
if ($type=="techreport") { if ($type=="techreport") {
$publisher = 'Technical report, '.$bibentry->getField("institution");
$publisher = __('Technical report').', '.$bibentry->getField("institution");
} }
if ($type=="misc") { if ($type=="misc") {
@ -1754,7 +1762,7 @@ function DefaultBibliographyStyle(&$bibentry) {
if ($publisher!='') $entry[] = '<span class="bibpublisher">'.$publisher.'</span>'; if ($publisher!='') $entry[] = '<span class="bibpublisher">'.$publisher.'</span>';
if ($bibentry->hasField('volume')) $entry[] = "volume ".$bibentry->getField("volume");
if ($bibentry->hasField('volume')) $entry[] = __('volume').' '.$bibentry->getField("volume");
if ($bibentry->hasField(YEAR)) $entry[] = $bibentry->getYear(); if ($bibentry->hasField(YEAR)) $entry[] = $bibentry->getYear();
@ -2260,11 +2268,12 @@ function query2title(&$query) {
// and we remove the regexp modifiers ^ $ // and we remove the regexp modifiers ^ $
$v = preg_replace('/[$^]/','',$v); $v = preg_replace('/[$^]/','',$v);
} }
$headers[$k] = ucwords($k).': '.ucwords(htmlspecialchars($v));
$headers[$k] = __(ucwords($k)).': '.ucwords(htmlspecialchars($v));
} }
// special cases // special cases
if (isset($headers[Q_ALL])) $headers[Q_ALL] = 'Publications in '.htmlspecialchars($_GET[Q_FILE]);
if (isset($headers[Q_AUTHOR])) $headers[Q_AUTHOR] = 'Publications of '.htmlspecialchars($_GET[Q_AUTHOR]);
if (isset($headers[Q_ALL])) $headers[Q_ALL] = __('Publications in').' '.htmlspecialchars($_GET[Q_FILE]);
if (isset($headers[Q_AUTHOR])) $headers[Q_AUTHOR] = __('Publications of')
.' '.htmlspecialchars($_GET[Q_AUTHOR]);
return join(' &amp; ',$headers); return join(' &amp; ',$headers);
} }
} }
@ -3500,8 +3509,10 @@ class Dispatcher {
return; return;
} }
if (!isset($_GET[Q_FILE])) { die('$_GET[\''.Q_FILE.'\'] is not set!'); }
// first we set the database (load from disk or parse the bibtex file) // first we set the database (load from disk or parse the bibtex file)
if (!isset($_GET[Q_DB])) { setDB(); }
if (!isset($_GET[Q_DB])) { zetDB(Q_FILE); }
// is the publication list included in another page? // is the publication list included in another page?
// strtr is used for Windows where __FILE__ contains C:\toto and SCRIPT_FILENAME contains C:/toto (bug reported by Marco) // strtr is used for Windows where __FILE__ contains C:\toto and SCRIPT_FILENAME contains C:/toto (bug reported by Marco)

Loading…
Cancel
Save