Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ jobs:
with:
php_versions: '["8.3"]'
bedita_version: '5'
coverage_min_percentage: 99

unit-6:
uses: bedita/github-workflows/.github/workflows/php-unit.yml@v2
with:
php_versions: '["8.4"]'
bedita_version: '6'
coverage_min_percentage: 99
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# I18n plugin for BEdita4 & CakePHP
# I18n plugin for BEdita & CakePHP

[![Github Actions](https://github.com/bedita/i18n/workflows/php/badge.svg)](https://github.com/bedita/i18n/actions?query=workflow%3Aphp)
[![codecov](https://codecov.io/gh/bedita/i18n/branch/master/graph/badge.svg)](https://codecov.io/gh/bedita/i18n)
Expand All @@ -9,7 +9,7 @@

## Installation

You can install this BEdita4/CakePHP plugin using [composer](http://getcomposer.org) like this:
You can install this BEdita/CakePHP plugin using [composer](http://getcomposer.org) like this:

```bash
composer require bedita/i18n
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bedita/i18n",
"description": "Internationalization plugin for BEdita 4 & CakePHP",
"description": "Internationalization plugin for BEdita & CakePHP",
"type": "cakephp-plugin",
"license": "LGPL-3.0-or-later",
"support": {
Expand Down Expand Up @@ -41,10 +41,16 @@
"@test",
"@cs-check"
],
"cs-setup": [
"vendor/bin/phpcs --config-set installed_paths vendor/cakephp/cakephp-codesniffer",
"vendor/bin/phpcs --config-set default_standard CakePHP",
"vendor/bin/phpcs --config-set colors 1"
],
"cs-check": "vendor/bin/phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"cs-fix": "vendor/bin/phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"stan": "vendor/bin/phpstan analyse",
"cs-check": "vendor/bin/phpcs",
"cs-fix": "vendor/bin/phpcbf",
"test": "vendor/bin/phpunit --colors=always",
"coverage": "vendor/bin/phpunit --colors=always --coverage-html coverage",
"update-dev": [
"@composer update",
"@cs-setup"
Expand Down
6 changes: 4 additions & 2 deletions src/Command/GettextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
'boolean' => true,
])
->addOption('locales', [
'help' => 'Comma separated list of locales to generate. Leave empty to use configuration `I18n.locales`',
'help' => 'Comma separated list of locales to generate. ' .
'Leave empty to use configuration `I18n.locales`',
'short' => 'l',
'default' => implode(',', array_keys((array)Configure::read('I18n.locales'))),
]);
Expand All @@ -125,7 +126,8 @@ public function execute(Arguments $args, ConsoleIo $io)

$resCmd = [];
exec('which msgmerge 2>&1', $resCmd);
$msg = empty($resCmd[0]) ? 'ERROR: msgmerge not available. Please install gettext utilities.' : 'OK: msgmerge found';
$errorMsg = 'ERROR: msgmerge not available. Please install gettext utilities.';
$msg = empty($resCmd[0]) ? $errorMsg : 'OK: msgmerge found';
$method = empty($resCmd[0]) ? 'abort' : 'out';
$io->{$method}($msg);

Expand Down
9 changes: 7 additions & 2 deletions src/Filesystem/Gettext.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function header(string $type = 'po'): string
$result = sprintf('msgid ""%smsgstr ""%s', "\n", "\n");
$contents = [
'po' => [
'Project-Id-Version' => 'BEdita 4',
'Project-Id-Version' => 'BEdita',
'POT-Creation-Date' => FrozenTime::now()->format('Y-m-d H:i:s'),
'PO-Revision-Date' => '',
'Last-Translator' => '',
Expand All @@ -79,7 +79,7 @@ public static function header(string $type = 'po'): string
'Content-Type' => 'text/plain; charset=utf-8',
],
'pot' => [
'Project-Id-Version' => 'BEdita 4',
'Project-Id-Version' => 'BEdita',
'POT-Creation-Date' => FrozenTime::now()->format('Y-m-d H:i:s'),
'MIME-Version' => '1.0',
'Content-Transfer-Encoding' => '8bit',
Expand All @@ -102,6 +102,8 @@ public static function header(string $type = 'po'): string
* - info: array of info messages
* - updated: boolean, true if file has been updated
*
* @param string $localePath Locale path
* @param array $translations Translations
* @return array
*/
public static function writeMasterPot(string $localePath, array $translations): array
Expand Down Expand Up @@ -145,6 +147,9 @@ public static function writeMasterPot(string $localePath, array $translations):
*
* - info: array of info messages
*
* @param array $locales Locales
* @param string $localePath Locale path
* @param array $translations Translations
* @return array
*/
public static function writePoFiles(array $locales, string $localePath, array &$translations): array
Expand Down
4 changes: 3 additions & 1 deletion src/Filesystem/Paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ public static function setupPlugins(array &$templatePaths, string &$localePath):
$acc,
array_filter(
(array)scandir($path),
fn ($file) => is_string($file) && !in_array($file, ['.', '..']) && Plugin::getCollection()->has($file)
fn ($file) => is_string($file)
&& !in_array($file, ['.', '..'])
&& Plugin::getCollection()->has($file)
)
),
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filesystem/GettextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testHeader(): void
$actual = Gettext::header();
static::assertTrue(strpos($actual, 'msgid ""') === 0);
static::assertTrue(strpos($actual, 'msgstr ""') > 0);
static::assertTrue(strpos($actual, 'Project-Id-Version: BEdita 4') > 0);
static::assertTrue(strpos($actual, 'Project-Id-Version: BEdita') > 0);
static::assertTrue(strpos($actual, 'Language-Team: BEdita I18N & I10N Team') > 0);
static::assertTrue(strpos($actual, 'MIME-Version: 1.0') > 0);
static::assertTrue(strpos($actual, 'Content-Transfer-Encoding: 8bit') > 0);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dir/messages.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
msgid ""
msgstr ""
"Project-Id-Version: BEdita 4 \n"
"Project-Id-Version: BEdita \n"
"POT-Creation-Date: 2023-06-20 11:06:15 \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
Expand Down
1 change: 1 addition & 0 deletions tests/test_dir/sample.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php
declare(strict_types=1);

echo __('Sample php');
Loading