public static function InitializeLanguage() { global $argv; if (strstr($_SERVER['REQUEST_URI'], '_devtools')) { return false; } if (strstr($_SERVER['REQUEST_URI'], 'image.php')) { return false; } if (strstr($_SERVER['REQUEST_URI'], 'profile.php')) { return false; } QApplication::$SourceLanguage = NarroLanguage::LoadByLanguageCode(__SOURCE_LANGUAGE_CODE__); // language passed through the l parameter if (@$_REQUEST['l']) { QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode(@$_REQUEST['l']); } elseif (isset($argv) && ($strLanguage = $argv[array_search('--translation-lang', $argv) + 1])) { QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode($strLanguage); } else { if (QApplication::$User->UserId != NarroUser::ANONYMOUS_USER_ID) { $objGuessedLanguage = NarroLanguage::LoadByLanguageCode(QApplication::$User->GetPreferenceValueByName('Language')); if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) { $objGuessedLanguage = null; } } if (!$objGuessedLanguage) { $objGuessedLanguage = QApplication::GetBrowserLanguage(); if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) { $objGuessedLanguage = null; } } if (!$objGuessedLanguage) { $objGuessedLanguage = NarroLanguage::QuerySingle(QQ::Equal(QQN::NarroLanguage()->Active, true)); } if (!$objGuessedLanguage) { die('There are no active languages in the database.'); } else { if (!isset($_REQUEST['openid_mode']) && !isset($argv)) { QApplication::Redirect(sprintf('projects.php?l=%s', $objGuessedLanguage->LanguageCode)); exit; } else { QApplication::$TargetLanguage = $objGuessedLanguage; } } } if (QApplication::$TargetLanguage->Active == false && !isset($argv)) { die(sprintf('The language %s is not active. Please ask the administrator to activate or check your URL if this is not the language you wanted.', QApplication::$TargetLanguage->LanguageName)); } }
NarroLogger::LogInfo(sprintf('The anonymous user id=%s does not exist in the database.', $intUserId)); return false; } } QApplication::$User = $objUser; $objProject = NarroProject::Load($intProjectId); if (!$objProject instanceof NarroProject) { NarroLogger::LogInfo(sprintf('Project with id=%s does not exist in the database.', $intProjectId)); return false; } $objLanguage = NarroLanguage::LoadByLanguageCode($strTargetLanguage); if (!$objLanguage instanceof NarroLanguage) { NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strTargetLanguage)); return false; } QApplication::$TargetLanguage = $objLanguage; $objNarroImporter->TargetLanguage = $objLanguage; NarroLogger::LogInfo(sprintf('Target language is %s', $objNarroImporter->TargetLanguage->LanguageName)); $objNarroImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode($strSourceLanguage); if (!$objNarroImporter->SourceLanguage instanceof NarroLanguage) { NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strSourceLanguage)); return false; } NarroLogger::LogInfo(sprintf('Source language is %s', $objNarroImporter->SourceLanguage->LanguageName)); $objNarroImporter->Project = $objProject; $objNarroImporter->User = $objUser; if (array_search('--template-directory', $argv) !== false) { $objNarroImporter->TemplatePath = $argv[array_search('--template-directory', $argv) + 1]; } else { $objNarroImporter->TemplatePath = $objNarroImporter->Project->DefaultTemplatePath; }
* Copyright (C) 2008-2011 Alexandru Szasz <*****@*****.**> * http://code.google.com/p/narro/ * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This program 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 General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/configuration/prepend.inc.php'; QApplication::$TargetLanguage = NarroLanguage::Load(QApplication::QueryString('l')); if (QApplication::QueryString('p')) { $objProject = NarroProject::Load(QApplication::QueryString('p')); } switch (QApplication::QueryString('t')) { case 'suggestion': if (isset($objProject) && $objProject instanceof NarroProject) { $strCacheId = sprintf('rssfeed_suggestion_%d_%d', $objProject->ProjectId, QApplication::QueryString('l')); } else { $strCacheId = sprintf('rssfeed_suggestion_%d', QApplication::QueryString('l')); } if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) { if (isset($objProject) && $objProject instanceof NarroProject) { $objRssFeed = new QRssFeed(sprintf(t('Translations for %s'), $objProject->ProjectName), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s for %s'), t(QApplication::$TargetLanguage->LanguageName), $objProject->ProjectName)); } else { $objRssFeed = new QRssFeed(sprintf(t('Translations for all projects'), t(QApplication::$TargetLanguage->LanguageName)), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s'), t(QApplication::$TargetLanguage->LanguageName)));