From 9e64dc2debfa1c7410f82bf71f4d10856751e258 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 20 May 2016 08:36:45 -0400
Subject: [PATCH] Remove application/x-tar file extension test as it might not exist in nginx config (#5253)

---
 bin/importgettext.sh |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/bin/importgettext.sh b/bin/importgettext.sh
index cc01c33..5a91e6b 100755
--- a/bin/importgettext.sh
+++ b/bin/importgettext.sh
@@ -1,7 +1,6 @@
 #!/usr/bin/env php
 <?php
 /*
-
  +-----------------------------------------------------------------------+
  | bin/importgettext.sh                                                  |
  |                                                                       |
@@ -14,12 +13,9 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
 require INSTALL_PATH.'program/include/clisetup.php';
 
 if ($argc < 2) {
@@ -39,7 +35,7 @@
 foreach ($out as $outfn => $texts) {
 	$lang = preg_match('!/([a-z]{2}(_[A-Z]{2})?)[./]!', $outfn, $m) ? $m[1] : '';
 	$varname = strpos($outfn, 'messages.inc') !== false ? 'messages' : 'labels';
-	
+
 	$header = <<<EOF
 <?php
 
@@ -54,24 +50,24 @@
  +-----------------------------------------------------------------------+
  | Author: %-62s|
  +-----------------------------------------------------------------------+
- @version %s$
 */
 
 $%s = array();
 
 EOF;
 
-	$output = sprintf($header, $lang, $varname.'.inc', date('Y'), $texts['_translator'], '$Id', $varname);
+	$author = preg_replace('/\s*<Unknown>/i', '', $texts['_translator']);
+	$output = sprintf($header, $lang, $varname.'.inc', date('Y'), $author, $varname);
 
 	foreach ($texts as $label => $value) {
-	    if (is_array($value)) { var_dump($outfn, $label, $value); exit; }
+		if (is_array($value)) { var_dump($outfn, $label, $value); exit; }
 		if ($label[0] != '_' && strlen($value))
 			$output .= sprintf("\$%s['%s'] = '%s';\n", $varname, $label, strtr(addcslashes($value, "'"), array("\r" => '', "\n" => '\n')));
 	}
 
 	$output .= "\n";
 	$dir = dirname($outfn);
-	@mkdir($dir, 664, true);
+	@mkdir($dir, 0755, true);
 	if (file_put_contents($outfn, $output))
 		echo "-> $outfn\n";
 }
@@ -99,6 +95,10 @@
 	$language = '';
 	$translator = '';
 
+	// get language code from file name
+	if (preg_match('/-([a-z_]+).po$/i', $fn, $m))
+	  $language = expand_langcode($m[1]);
+
 	$is_header = true;
 	$msgid = null;
 	$msgstr = '';
@@ -125,9 +125,10 @@
 				foreach ($dests as $dest) {
 					list($file, $label) = explode(':', $dest);
 					$out[$file][$label] = $msgstr;
+					$out[$file]['_translator'] = $translator;
 				}
 			}
-			
+
 			$msgid = null;
 			$msgstr = '';
 			$dests = array();
@@ -163,7 +164,7 @@
 			$out[$file]['_translator'] = $translator;
 		}
 	}
-	
+
 	return $language ? $out : array();
 }
 

--
Gitblit v1.9.1