Edgard 6 лет назад
Родитель
Сommit
064bca2e9d
4 измененных файлов с 59 добавлено и 21 удалено
  1. 10 8
      locales/en_GB.po
  2. 7 5
      locales/pt_BR.po
  3. 7 5
      locales/singlesignon.pot
  4. 35 3
      tools/update-locales.php

+ 10 - 8
locales/en_GB.po

@@ -1,18 +1,20 @@
-# English translations for PACKAGE package.
-# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
+# English translations for singlesignon package.
+# Copyright (C) 2019 THE singlesignon'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the singlesignon package.
 # Automatically generated, 2019.
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-04-26 15:28-0300\n"
-"PO-Revision-Date: 2019-04-26 15:28-0300\n"
+"Project-Id-Version: singlesignon 1.0.0\n"
+"Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
+"issues\n"
+"POT-Creation-Date: 2019-04-29 09:32-0300\n"
+"PO-Revision-Date: 2019-04-29 09:32-0300\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
+"Language: en_GB\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 

+ 7 - 5
locales/pt_BR.po

@@ -1,18 +1,20 @@
-# Portuguese translations for PACKAGE package.
-# Copyright (C) 2019 THE PACKAGE'S COPYRIGHT HOLDER
+# Portuguese translations for singlesignon package.
+# Copyright (C) 2019 THE singlesignon'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the PACKAGE package.
 # Automatically generated, 2019.
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
+"Project-Id-Version: singlesignon 1.0.0\n"
+"Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
+"issues\n"
 "POT-Creation-Date: 2019-04-26 15:28-0300\n"
 "PO-Revision-Date: 2019-04-26 11:04-0300\n"
 "Last-Translator: Edgard Lorraine Messias <edgardmessias@gmail.com>\n"
 "Language-Team: none\n"
+"Language: pt_BR\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 

+ 7 - 5
locales/singlesignon.pot

@@ -1,19 +1,21 @@
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
+# This file is distributed under the same license as the singlesignon package.
 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 #
 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-04-26 15:28-0300\n"
+"Project-Id-Version: singlesignon 1.0.0\n"
+"Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
+"issues\n"
+"POT-Creation-Date: 2019-04-29 09:32-0300\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
 #: hook.php:22

+ 35 - 3
tools/update-locales.php

@@ -5,11 +5,43 @@ function log_and_exec($cmd) {
    return shell_exec($cmd);
 }
 
+if (!function_exists('glob_recursive')) {
+
+   // Does not support flag GLOB_BRACE
+   function glob_recursive($pattern, $flags = 0) {
+      $files = glob($pattern, $flags);
+      foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
+         $files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags));
+      }
+      return $files;
+   }
+
+}
+
 $dir = dirname(dirname(__FILE__));
 
-log_and_exec("xgettext *.php */*.php -D $dir -o $dir/locales/singlesignon.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po --keyword=__sso");
+include_once "$dir/setup.php";
+
+$file_list = glob_recursive("*.php");
+
+$file_list = array_filter($file_list, function($f) {
+   return strpos($f, "vendor") === false;
+});
+
+$source_files = implode(" ", $file_list);
+
+putenv("LANG=C");
+log_and_exec("xgettext $source_files -D $dir -o $dir/locales/singlesignon.pot" .
+      " -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po --keyword=__sso" .
+      " --package-name=singlesignon --package-version=" . PLUGIN_SINGLESIGNON_VERSION . 
+      " --msgid-bugs-address=https://github.com/edgardmessias/glpi-singlesignon/issues");
+
+// Replace some KEYWORDS
+$pot_content = file_get_contents("$dir/locales/singlesignon.pot");
+$pot_content = str_replace("CHARSET", "UTF-8", $pot_content);
+file_put_contents("$dir/locales/singlesignon.pot", $pot_content);
 
-log_and_exec("msginit --no-translator -i $dir/locales/singlesignon.pot -l en_GB -o $dir/locales/en_GB.po");
+log_and_exec("msginit --no-translator -i $dir/locales/singlesignon.pot -l en_GB.UTF8 -o $dir/locales/en_GB.po");
 
 $files = glob("$dir/locales/*.po");
 
@@ -18,7 +50,7 @@ foreach ($files as $file) {
    $lang = basename($file, ".po");
 
    if ($lang !== "en_GB") {
-      log_and_exec("msgmerge --update $dir/locales/$lang.po $dir/locales/singlesignon.pot");
+      log_and_exec("msgmerge --update $dir/locales/$lang.po $dir/locales/singlesignon.pot --lang=$lang --backup=off");
    }
 
    log_and_exec("msgfmt $dir/locales/$lang.po -o $dir/locales/$lang.mo");