function generateScriptTags($prependedWhitespace = '') { global $runningOnLive; global $language; $returnString = ''; if ($runningOnLive) { $buildNumber = intval(file_get_contents('release/mc_rss-min.js_build#')); $returnString = $prependedWhitespace . '<script type="text/javascript" src="release/mc_rss-min.js?b=' . $buildNumber . '"></script>' . PHP_EOL; $languageBuildNumber = intval(file_get_contents('release/locals/' . $language . '.js_build#')); $returnString .= $prependedWhitespace . '<script type="text/javascript" src="release/locals/' . $language . '.js?b=' . $languageBuildNumber . '"></script>' . PHP_EOL; } else { $returnString .= $prependedWhitespace . '<!-- BEGIN GENERATED SCRIPT TAGS -->' . PHP_EOL; $fileList = file('src/_fileList.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); for ($i = 0; $i < count($fileList); $i++) { if (substr($fileList[$i], 0, 1) == ';') { continue; } //Ignore lines beginning with a semicolon as these are comments $returnString .= $prependedWhitespace . '<script type="text/javascript" src="' . str_replace("\\", '/', $fileList[$i]) . '"></script>' . PHP_EOL; } $returnString .= $prependedWhitespace . '<!-- END GENERATED SCRIPT TAGS -->' . PHP_EOL; $returnString .= PHP_EOL; $returnString .= $prependedWhitespace . '<!-- BEGIN LOCALIZATION STRINGS -->' . PHP_EOL; $localizationData = json_encode(localization::getLanguageStrings($language)); $returnString .= $prependedWhitespace . '<script type="text/javascript">localizationStrings = ' . $localizationData . ';</script>' . PHP_EOL; $returnString .= $prependedWhitespace . '<!-- END LOCALIZATION STRINGS -->' . PHP_EOL; } return $returnString; }
public function generateLocalizationFiles() { foreach (localization::getLanguageList() as $languageCode => $languageName) { $file_jsFile = $this->outputPath . "/locals/" . $languageCode . ".js"; $file_buildNumber = $file_jsFile . "_build#"; $newContents = "localizationStrings = " . json_encode(localization::getLanguageStrings($languageCode), JSON_FORCE_OBJECT) . ";"; $md5_existing = file_exists($file_jsFile) ? md5_file($file_jsFile) : false; $buildNumber = file_exists($file_buildNumber) ? file_get_contents($file_buildNumber) : 1; if ($md5_existing != md5($newContents) || !file_exists($file_jsFile)) { file_put_contents($file_buildNumber, ++$buildNumber); file_put_contents($file_jsFile, $newContents); echo " Wrote new {$languageCode} to disk." . PHP_EOL; } else { echo " Skipped {$languageCode} as content is unchanged." . PHP_EOL; } } }
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ header('Content-type: application/json; charset=UTF-8'); include_once 'includes/utf8_handling.php'; include_once 'includes/class_localization.php'; ob_start("ob_gzhandler"); if (!isset($_REQUEST["task"])) { $get_task = "getList"; } else { $get_task = $_REQUEST["task"]; } switch ($get_task) { case "getLang": if (!isset($_REQUEST["lang"])) { $lang = "en_US"; } else { $lang = $_REQUEST["lang"]; } echo json_encode(localization::getLanguageStrings($lang)); break; default: echo json_encode(localization::getLanguageList()); break; }