Browse Source

Fix language if it is not found in the i18n. Reported by le_

master
Sébastien Lucas 10 years ago
parent
commit
c84cec9516
3 changed files with 15 additions and 4 deletions
  1. +4
    -1
      base.php
  2. +1
    -1
      book.php
  3. +10
    -2
      language.php

+ 4
- 1
base.php View File

@@ -169,7 +169,10 @@ function localize($phrase, $count=-1) {
$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) {


+ 1
- 1
book.php View File

@@ -227,7 +227,7 @@ class Book extends Base {
$result->execute (array ($this->id));
while ($post = $result->fetchObject ())
{
array_push ($lang, localize("languages.".$post->lang_code));
array_push ($lang, Language::getLanguageString($post->lang_code));
}
return implode (", ", $lang);
}


+ 10
- 2
language.php View File

@@ -26,6 +26,14 @@ class language extends Base {
public function getEntryId () {
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() {
$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->execute (array ($languageId));
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;
}
@@ -57,7 +65,7 @@ order by languages.lang_code');
while ($post = $result->fetchObject ())
{
$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",
array ( new LinkNavigation ($language->getUri ()))));
}


Loading…
Cancel
Save