From: Antoine Musso Date: Tue, 16 Aug 2005 19:27:31 +0000 (+0000) Subject: Add a dummy header (charset=UTF-8), fix escaping, pot generated first X-Git-Tag: 1.6.0~1937 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=d64586b23bcf9c962bd73dbf989cb523f394da21;p=lhc%2Fweb%2Fwiklou.git Add a dummy header (charset=UTF-8), fix escaping, pot generated first --- diff --git a/maintenance/lang2po.php b/maintenance/lang2po.php index a693b6dbff..4e7ebae4b6 100644 --- a/maintenance/lang2po.php +++ b/maintenance/lang2po.php @@ -13,7 +13,8 @@ require_once('languages.inc'); define('ALL_LANGUAGES', true); define('XGETTEXT_BIN', 'xgettext'); -define('XGETTEXT_OPTIONS', '-n --keyword=wfMsg'); +define('MSGINIT_BIN', 'msginit'); +define('XGETTEXT_OPTIONS', '-n --keyword=wfMsg '); define('LOCALE_OUTPUT_DIR', $IP.'/locale'); @@ -32,6 +33,32 @@ END; } +/** + * Return a dummy header for later edition. + * @return string A dummy header + */ +function poHeader() { +return +'# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2005 MediaWiki +# This file is distributed under the same license as the MediaWiki package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: bugzilllaaaaa\n" +"POT-Creation-Date: 2005-08-16 20:13+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: VARIOUS \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +'; +} + /** * generate and write a file in .po format. * @@ -40,17 +67,20 @@ END; * @return string Filename where stuff got saved or false. */ function generatePo($langcode, &$messages) { - $data = ''; // TODO a .po header ? + $data = poHeader(); // Generate .po entries foreach($messages as $identifier => $content) { $data .= "msgid \"$identifier\"\n"; - // Double quotes escaped for $content: - $tmp = 'msgstr "'.str_replace('"', '\"', $content)."\""; - // New line should end with "\n not \n - $data .= str_replace("\n", "\"\n\"", $tmp); - $data .= "\n\n"; + // Escape backslashes + $tmp = str_replace('\\', '\\\\', $content); + // Escape doublelquotes + $tmp = preg_replace( "/(?getList() as $langcode) { } } } - -// Generate a default .po based source tree -echo "Getting 'gettext' default messages from sources\n"; -exec( XGETTEXT_BIN - .' '.XGETTEXT_OPTIONS - .' -o '.$IP.'/locale/wfMsg.po' - .' '.$IP.'/includes/*php' - ); - - ?>