Esempio n. 1
0
 /**
  * The method for translating a string into the current language
  * @param string $string : string to translate
  * @param mixed $params : non mandatory string or array of params. each param will replace the corresponding patterns '%s', '%s' (, etc...) in the translated string
  **/
 public static function __($string, $params = null)
 {
     //echo "<br/> Translate [".$string."]";
     //sympa: in the case some dev has forgotten to init the linguistic data properly
     if (!isset($_SESSION['ARFramework_lang']) || !isset(Lang::$_dictionary)) {
         //echo "<br/> but first have to init language";
         Lang::initLanguage();
     }
     //now look for the string in the current dictionary and return the translated string
     if (isset(Lang::$_dictionary[$string])) {
         if (Lang::$_dictionary[$string] == "") {
             if (Lang::$_replace_blank_translation_by == Lang::REPLACE_BY_BLANK) {
                 return "";
             } elseif (Lang::$_replace_blank_translation_by == Lang::REPLACE_BY_KEY) {
                 return $string;
             } elseif (Lang::$_replace_blank_translation_by == Lang::REPLACE_BY_KEY_TRANSLATE_ME) {
                 return $string . " [translate me]";
             }
         } else {
             if ($params == null) {
                 return Lang::$_dictionary[$string];
             } else {
                 return sprintf(Lang::$_dictionary[$string], $params);
             }
         }
     }
     //in the case the string wouldn't be found in the dictionary
     if (self::LANG_TRANSLATION_ASSISTANCE && !isset(Lang::$_untranslated_dictionary[$string])) {
         Lang::$_untranslated_dictionary[$string] = isset($params) && is_array($params) ? count($params) : ($params != "" ? 1 : 0);
     }
     if (Lang::$_replace_non_existing_translation_by == Lang::REPLACE_BY_BLANK) {
         return "";
     } elseif (Lang::$_replace_non_existing_translation_by == Lang::REPLACE_BY_KEY) {
         return $string;
     } elseif (Lang::$_replace_non_existing_translation_by == Lang::REPLACE_BY_KEY_TRANSLATE_ME) {
         return $string . " [translate me]";
     }
     //in any other case (shouldn't happen):
     return $string . " [translate me]";
     //
 }
Esempio n. 2
0
 /**
  * Init Framework classes
  */
 protected static function ini()
 {
     Alias::ini(self::$root);
     Sys::ini();
     Url::ini();
     Path::ini();
     Template::run();
     Faker::ini();
     Links::ini();
     Errors::ini(self::$root);
     License::ini(self::$page);
     //langues
     Lang::setReplaceBlankTranslationBy(Lang::REPLACE_BY_BLANK);
     Lang::setReplaceNonExistingTranslationBy(Lang::REPLACE_BY_KEY_TRANSLATE_ME);
     Lang::initLanguage();
     Database::ini();
     Auth::ini();
     Plugins::ini();
     Widgets::ini();
 }