--conf option for specifying a different LocalSettings.php. This allows multiple...
[lhc/web/wiklou.git] / maintenance / lang2po.php
index 2976a7e..af6bcee 100644 (file)
@@ -15,12 +15,14 @@ define('ALL_LANGUAGES',    true);
 define('XGETTEXT_BIN',     'xgettext');
 define('MSGMERGE_BIN',     'msgmerge');
 
-define('XGETTEXT_OPTIONS', '-n --keyword=wfMsg ');
+// used to generate the .pot
+define('XGETTEXT_OPTIONS', '-n --keyword=wfMsg --keyword=wfMsgForContent --keyword=wfMsgHtml --keyword=wfMsgWikiHtml ');
+define('MSGMERGE_OPTIONS', ' -v ');
 
 define('LOCALE_OUTPUT_DIR', $IP.'/locale');
 
 
-if( isset($options['help']) ) { usage(); die(); }
+if( isset($options['help']) ) { usage(); wfDie(); }
 // default output is WikiText
 if( !isset($options['lang']) ) { $options['lang'] = ALL_LANGUAGES; }
 
@@ -39,7 +41,7 @@ END;
  * @return string A dummy header
  */
 function poHeader() {
-return 
+return
 '# SOME DESCRIPTIVE TITLE.
 # Copyright (C) 2005 MediaWiki
 # This file is distributed under the same license as the MediaWiki package.
@@ -99,6 +101,18 @@ function generatePo($langcode, &$messages) {
        }
 }
 
+function generatePot() {
+       global $IP;
+       $curdir = getcwd();
+       chdir($IP);
+       exec( XGETTEXT_BIN
+         .' '.XGETTEXT_OPTIONS
+         .' -o '.LOCALE_OUTPUT_DIR.'/wfMsg.pot'
+         .' includes/*php'
+         );
+       chdir($curdir);
+}
+
 function applyPot($langcode) {
        $langdir = LOCALE_OUTPUT_DIR.'/'.$langcode;
 
@@ -106,19 +120,15 @@ function applyPot($langcode) {
        $pot = LOCALE_OUTPUT_DIR.'/wfMsg.pot';
        $dest = $langdir.'/messages.po';
 
-       // Merge template and generate file to get final .po    
-       exec(MSGMERGE_BIN." $from $pot -o $dest ");
+       // Merge template and generate file to get final .po
+       exec(MSGMERGE_BIN.MSGMERGE_OPTIONS." $from $pot -o $dest ");
        // delete no more needed file
-       unlink($from);
+//     unlink($from);
 }
 
 // Generate a template .pot based on source tree
 echo "Getting 'gettext' default messages from sources:";
-exec( XGETTEXT_BIN
-  .' '.XGETTEXT_OPTIONS
-  .' -o '.$IP.'/locale/wfMsg.pot'
-  .' '.$IP.'/includes/*php'
-  );
+generatePot();
 echo "done.\n";