From bec6d3656080ad4520ab10a0d7f19202e8e60c2e Mon Sep 17 00:00:00 2001 From: David Martinez Date: Wed, 7 Aug 2019 00:22:13 +0200 Subject: [PATCH 1/2] Added \r to \Gettext\Generators\Po::convertString(), related with #218 --- src/Generators/Po.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Generators/Po.php b/src/Generators/Po.php index 136ea5c7..d059361e 100644 --- a/src/Generators/Po.php +++ b/src/Generators/Po.php @@ -136,6 +136,7 @@ public static function convertString($value) "\x00" => '', '\\' => '\\\\', "\t" => '\t', + "\r" => '\r', "\n" => '\n', '"' => '\\"', ] From 7f0a32b5a19b02244f45f9ffebf0120e3fd78ed9 Mon Sep 17 00:00:00 2001 From: David Martinez Date: Tue, 1 Oct 2019 20:03:30 +0200 Subject: [PATCH 2/2] Sort output option added to Po generator --- src/Generators/Po.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Generators/Po.php b/src/Generators/Po.php index d059361e..0fbe1c9c 100644 --- a/src/Generators/Po.php +++ b/src/Generators/Po.php @@ -2,12 +2,14 @@ namespace Gettext\Generators; +use Gettext\Translation; use Gettext\Translations; class Po extends Generator implements GeneratorInterface { public static $options = [ 'noLocation' => false, + 'sortOutput' => false, ]; /** @@ -27,6 +29,12 @@ public static function toString(Translations $translations, array $options = []) $lines[] = ''; + if ($options['sortOutput'] == true) { + $translations->uasort(function (Translation $translation1, Translation $translation2) { + return strcmp($translation1->getOriginal(), $translation2->getTranslation()); + }); + } + //Translations foreach ($translations as $translation) { if ($translation->hasComments()) {