Skip to content

Commit

Permalink
Merge(dev) Rename namespace to Wdes\phpI18nL10n
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Mar 29, 2020
2 parents 7b7b6fd + 79caeda commit 63d0467
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Upgraded squizlabs/php_codesniffer from 3.3.x to 3.5.x
- Upgraded phpstan/phpstan from 0.11.8+ to 0.12+
- BREAKING CHANGE rename namespace to Wdes\phpI18nL10n

### Fixed
- Test phpunit suite
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
],
"autoload": {
"psr-4": {
"Wdes\\PIL\\": "src/"
"Wdes\\phpI18nL10n\\": "src/"
}
},
"autoload-dev": {
Expand Down
6 changes: 3 additions & 3 deletions example/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

require_once __DIR__ . '/../vendor/autoload.php';

use \Wdes\PIL\plugins\MoReader;
use \Wdes\PIL\Launcher;
use \Wdes\PIL\Twig\Extension\I18n as ExtensionI18n;
use \Wdes\phpI18nL10n\plugins\MoReader;
use \Wdes\phpI18nL10n\Launcher;
use \Wdes\phpI18nL10n\Twig\Extension\I18n as ExtensionI18n;
use \Twig\Environment as TwigEnvironment;
use \Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;

Expand Down
2 changes: 1 addition & 1 deletion scripts/tools/generate-twig-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

require_once(__DIR__ . '/../../vendor/autoload.php');

use \Wdes\PIL\Twig\Extension\I18n as ExtensionI18n;
use \Wdes\phpI18nL10n\Twig\Extension\I18n as ExtensionI18n;
use \Twig\Cache\FilesystemCache;
use \Twig\Environment as TwigEnvironment;
use \Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
Expand Down
4 changes: 2 additions & 2 deletions src/Launcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL;
namespace Wdes\phpI18nL10n;

use \Wdes\PIL\plugins\BasePlugin;
use Wdes\phpI18nL10n\plugins\BasePlugin;

/**
* Plugin for reading .mo files
Expand Down
6 changes: 3 additions & 3 deletions src/Twig/Extension/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL\Twig\Extension;
namespace Wdes\phpI18nL10n\Twig\Extension;

use Wdes\PIL\Twig\TokenParser;
use Wdes\phpI18nL10n\Twig\TokenParser;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

Expand All @@ -25,7 +25,7 @@ public function getFilters(): array
{
return [
new TwigFilter(
'trans', '\Wdes\PIL\Launcher::gettext'
'trans', '\Wdes\phpI18nL10n\Launcher::gettext'
),
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/MemoryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL\Twig;
namespace Wdes\phpI18nL10n\Twig;

use \Twig\Cache\CacheInterface;
use \Twig\TemplateWrapper;
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/TokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL\Twig;
namespace Wdes\phpI18nL10n\Twig;

use \Wdes\PIL\Twig\TranslationNode;
use Wdes\phpI18nL10n\Twig\TranslationNode;
use Twig\Error\SyntaxError;
use Twig\Node\Expression\NameExpression;
use Twig\Node\Node;
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/TranslationNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace Wdes\PIL\Twig;
namespace Wdes\phpI18nL10n\Twig;

use Twig\Compiler;
use Twig\Node\Expression\AbstractExpression;
Expand Down Expand Up @@ -75,7 +75,7 @@ public function compile(Compiler $compiler): void
$vars = array_merge($vars, $Pvars);
}

$prefix = '\Wdes\PIL\Launcher::getPlugin()->';
$prefix = '\Wdes\phpI18nL10n\Launcher::getPlugin()->';
if ($this->hasNode('context')) {
$function = $this->hasNode('plural') ? 'ngettext' : 'pgettext';
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/BasePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL\plugins;
namespace Wdes\phpI18nL10n\plugins;

/**
* Plugin interface
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/MoReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace Wdes\PIL\plugins;
namespace Wdes\phpI18nL10n\plugins;

use \Wdes\PIL\plugins\BasePlugin;
use Wdes\phpI18nL10n\plugins\BasePlugin;
use \Exception;
use \stdClass;

Expand Down
29 changes: 15 additions & 14 deletions tests/I18nTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
namespace Wdes\phpI18nL10n\Tests;

use \PHPUnit\Framework\TestCase;
use \Wdes\PIL\Twig\Extension\I18n as ExtensionI18n;
use Wdes\phpI18nL10n\Twig\Extension\I18n as ExtensionI18n;
use \Twig\Environment as TwigEnv;
use \Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
use \Wdes\PIL\plugins\MoReader;
use \Wdes\PIL\Launcher;
use \Wdes\PIL\Twig\MemoryCache;
use Wdes\phpI18nL10n\plugins\MoReader;
use Wdes\phpI18nL10n\Launcher;
use Wdes\phpI18nL10n\Twig\MemoryCache;

/**
* @author William Desportes <[email protected]>
Expand Down Expand Up @@ -72,7 +72,7 @@ public function testSimpleTranslation(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo \Wdes\PIL\Launcher::getPlugin()->gettext("Translate this");',
'echo \Wdes\phpI18nL10n\Launcher::getPlugin()->gettext("Translate this");',
$generatedCode
);
$html = $template->render([]);
Expand All @@ -91,7 +91,7 @@ public function testSimpleTranslationWithComment(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo \Wdes\PIL\Launcher::getPlugin()->gettext("Translate this");',
'echo \Wdes\phpI18nL10n\Launcher::getPlugin()->gettext("Translate this");',
$generatedCode
);
$this->assertStringContainsString(
Expand All @@ -115,7 +115,7 @@ public function testSimpleTranslationWithContext(): void
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);

$this->assertStringContainsString(
'echo \Wdes\PIL\Launcher::getPlugin()->pgettext("NayanCat", "Translate this");',
'echo \Wdes\phpI18nL10n\Launcher::getPlugin()->pgettext("NayanCat", "Translate this");',
$generatedCode
);
$html = $template->render([]);
Expand All @@ -135,7 +135,8 @@ public function testSimpleTranslationWithContextAndVariable(): void
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);

$this->assertStringContainsString(
'echo strtr(\Wdes\PIL\Launcher::getPlugin()->pgettext("The user name", "Translate this %name%"), ["%name%" => ($context["name"] ?? null)]);',
'echo strtr(\Wdes\phpI18nL10n\Launcher::getPlugin()->pgettext("The user name", "Translate this %name%"), '
. '["%name%" => ($context["name"] ?? null)]);',
$generatedCode
);
$html = $template->render(
Expand All @@ -159,7 +160,7 @@ public function testSimpleTranslationWithContextAndVariables(): void
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);

$this->assertStringContainsString(
'echo strtr(\Wdes\PIL\Launcher::getPlugin()->pgettext("The user name", "Translate this %key%: %value%"), '
'echo strtr(\Wdes\phpI18nL10n\Launcher::getPlugin()->pgettext("The user name", "Translate this %key%: %value%"), '
. '["%key%" => ($context["key"] ?? null), "%value%" => ($context["value"] ?? null)]);',
$generatedCode
);
Expand All @@ -184,7 +185,7 @@ public function testPluralTranslation(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo strtr(\Wdes\PIL\Launcher::getPlugin()->ngettext("One person"'.
'echo strtr(\Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext("One person"'.
', "%nbr% persons", abs(($context["nbr_persons"] ?? null))),'.
' ["%nbr%" => ($context["nbr"] ?? null)]);',
$generatedCode
Expand All @@ -205,7 +206,7 @@ public function testPluralTranslationWithComment(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo strtr(\Wdes\PIL\Launcher::getPlugin()->ngettext('.
'echo strtr(\Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext('.
'"one user likes this.", "%nbr% users likes this.",'.
' abs(($context["nbr_persons"] ?? null))),'.
' ["%nbr%" => ($context["nbr"] ?? null)]);',
Expand All @@ -231,7 +232,7 @@ public function testSimplePluralTranslation(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo \Wdes\PIL\Launcher::getPlugin()->ngettext("One person", "persons", abs(($context["a"] ?? null)));',
'echo \Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext("One person", "persons", abs(($context["a"] ?? null)));',
$generatedCode
);
$html = $template->render(["nbr" => 5]);
Expand All @@ -252,7 +253,7 @@ public function testSimplePluralTranslationCount(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo \Wdes\PIL\Launcher::getPlugin()->ngettext("One person",'.
'echo \Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext("One person",'.
' "persons", abs(twig_get_attribute($this->env, $this->source,'.
' ($context["a"] ?? null), "count", [], "any", false, false, false, 1)));',
$generatedCode
Expand All @@ -273,7 +274,7 @@ public function testSimplePluralTranslationCountAndVars(): void
);
$generatedCode = $this->memoryCache->extractDoDisplayFromCache($template);
$this->assertStringContainsString(
'echo strtr(\Wdes\PIL\Launcher::getPlugin()->ngettext("One person",'.
'echo strtr(\Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext("One person",'.
' "persons and %count% dogs", abs(twig_get_attribute($this->env,'.
' $this->source, ($context["a"] ?? null), "count", [], "any", false, false, false, 1))),'.
' ["%count%" => abs(twig_get_attribute($this->env,'.
Expand Down
4 changes: 2 additions & 2 deletions tests/LauncherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace Wdes\phpI18nL10n\Tests;

use \PHPUnit\Framework\TestCase;
use \Wdes\PIL\plugins\MoReader;
use \Wdes\PIL\Launcher;
use Wdes\phpI18nL10n\plugins\MoReader;
use Wdes\phpI18nL10n\Launcher;

/**
* Test class for Utils
Expand Down
2 changes: 1 addition & 1 deletion tests/MoReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Exception;
use PHPUnit\Framework\TestCase;
use Wdes\PIL\plugins\MoReader;
use Wdes\phpI18nL10n\plugins\MoReader;
use \stdClass;

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TranslationNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Twig\Node\Expression\NameExpression;
use \Twig\Environment as TwigEnv;
use \Twig\Loader\FilesystemLoader as TwigLoaderFilesystem;
use \Wdes\PIL\Twig\TranslationNode;
use \Wdes\PIL\Twig\MemoryCache;
use Wdes\phpI18nL10n\Twig\TranslationNode;
use Wdes\phpI18nL10n\Twig\MemoryCache;

/**
* @author William Desportes <[email protected]>
Expand Down

0 comments on commit 63d0467

Please sign in to comment.