Fix language if it is not found in the i18n. Reported by le_
This commit is contained in:
parent
4aa3529131
commit
c84cec9516
5
base.php
5
base.php
|
@ -169,7 +169,10 @@ function localize($phrase, $count=-1) {
|
||||||
$translations = array_merge ($translations_en, $translations);
|
$translations = array_merge ($translations_en, $translations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $translations[$phrase];
|
if (array_key_exists ($phrase, $translations)) {
|
||||||
|
return $translations[$phrase];
|
||||||
|
}
|
||||||
|
return $phrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addURLParameter($urlParams, $paramName, $paramValue) {
|
function addURLParameter($urlParams, $paramName, $paramValue) {
|
||||||
|
|
2
book.php
2
book.php
|
@ -227,7 +227,7 @@ class Book extends Base {
|
||||||
$result->execute (array ($this->id));
|
$result->execute (array ($this->id));
|
||||||
while ($post = $result->fetchObject ())
|
while ($post = $result->fetchObject ())
|
||||||
{
|
{
|
||||||
array_push ($lang, localize("languages.".$post->lang_code));
|
array_push ($lang, Language::getLanguageString($post->lang_code));
|
||||||
}
|
}
|
||||||
return implode (", ", $lang);
|
return implode (", ", $lang);
|
||||||
}
|
}
|
||||||
|
|
12
language.php
12
language.php
|
@ -26,6 +26,14 @@ class language extends Base {
|
||||||
public function getEntryId () {
|
public function getEntryId () {
|
||||||
return self::ALL_LANGUAGES_ID.":".$this->id;
|
return self::ALL_LANGUAGES_ID.":".$this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getLanguageString ($code) {
|
||||||
|
$string = localize("languages.".$code);
|
||||||
|
if (preg_match ("/^languages/", $string)) {
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getCount() {
|
public static function getCount() {
|
||||||
$nLanguages = parent::getDb ()->query('select count(*) from languages')->fetchColumn();
|
$nLanguages = parent::getDb ()->query('select count(*) from languages')->fetchColumn();
|
||||||
|
@ -40,7 +48,7 @@ class language extends Base {
|
||||||
$result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?');
|
$result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?');
|
||||||
$result->execute (array ($languageId));
|
$result->execute (array ($languageId));
|
||||||
if ($post = $result->fetchObject ()) {
|
if ($post = $result->fetchObject ()) {
|
||||||
return new Language ($post->id, localize("languages.".$post->lang_code));
|
return new Language ($post->id, Language::getLanguageString ($post->lang_code));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +65,7 @@ order by languages.lang_code');
|
||||||
while ($post = $result->fetchObject ())
|
while ($post = $result->fetchObject ())
|
||||||
{
|
{
|
||||||
$language = new Language ($post->id, $post->lang_code);
|
$language = new Language ($post->id, $post->lang_code);
|
||||||
array_push ($entryArray, new Entry (localize("languages.".$language->lang_code), $language->getEntryId (),
|
array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (),
|
||||||
str_format (localize("bookword", $post->count), $post->count), "text non",
|
str_format (localize("bookword", $post->count), $post->count), "text non",
|
||||||
array ( new LinkNavigation ($language->getUri ()))));
|
array ( new LinkNavigation ($language->getUri ()))));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue