Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
51c58e0
Add FileValidator-Function for composer.json
Crizz0 Sep 25, 2025
4b49c5b
Add preg_match limiter /
Crizz0 Sep 25, 2025
42d3e74
Repair language-iso and name check of composer.json
Crizz0 Sep 25, 2025
c8e6b9a
Remove ValidateIsoTest.php from tests/
Crizz0 Sep 25, 2025
8449fc3
Change plural-rule guessing to composer.json
Crizz0 Sep 26, 2025
40177ad
Use a separate function for recaptcha and turnstile lang-key check
Crizz0 Sep 26, 2025
06cc5ae
Use a dedi function to open the composer.json
Crizz0 Sep 26, 2025
1451e78
Fix tests for Validate Captchas
Crizz0 Sep 26, 2025
de46382
Add check for valid language iso in composer.json
Crizz0 Sep 26, 2025
a107d46
Change required license to GPL-2.0-only
Crizz0 Sep 26, 2025
46a206b
Add 4.0/ to ignored directories
Crizz0 Sep 26, 2025
48177df
Repair version format check
Crizz0 Sep 26, 2025
8b4bbad
Check for correct type
Crizz0 Sep 26, 2025
616a8a7
Add URL check for homepage
Crizz0 Sep 26, 2025
9d21818
Check text direction has 1 of 2 valid values
Crizz0 Sep 26, 2025
a57fd86
Change some JSON-check error levels and messages
Crizz0 Sep 26, 2025
2f5d75e
Repair tests for Recaptcha
Crizz0 Sep 26, 2025
44453b7
Update Readme.md for better looks and recent status
Crizz0 Sep 26, 2025
c4d3d6c
Formatting and typo fixes
Crizz0 Sep 26, 2025
ca6c80c
Add safe-mode functionality again to guessPluralRule()
Crizz0 Sep 26, 2025
b1e4668
Correct some idents
Crizz0 Sep 26, 2025
abf36b6
Fix direction for FileListValidator.php
Crizz0 Sep 26, 2025
a78a007
Add a ! to preg_match of english-name value check
Crizz0 Sep 26, 2025
9111275
Repair tests for 4.0 in FileListValidator
Crizz0 Sep 27, 2025
45f3e8e
Add a composer.json to fixtures for direction
Crizz0 Sep 27, 2025
fe6e927
Add composer.json to source and remove common.php
Crizz0 Sep 27, 2025
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/vendor/
/.idea/
/bin/
/3.2/
/3.3/
/4.0/
61 changes: 41 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,60 @@
# phpBB Translation Validator - master-dev
# phpBB Translation Validator

This console application allows you to validate [phpBB](https://www.phpbb.com) language packages.
With the help of this command line application you are able
to validate [phpBB](https://www.phpbb.com) language packs.
This application runs on your local machine and can be integrated
into a [GitHub](https://www.github.com) repository.

## Requirements
## 📋Requirements

This tool requires PHP 8.1 or above.
This tool requires PHP 8.1 or above. In addition it needs several
symfony and other packages, which need to be downloaded and installed with [Composer](https://getcomposer.org).

### Installation

Firstly, download the latest British English (`en`) [language pack from phpBB.com](http://www.phpbb.com/customise/db/translation/british_english/) as this is the default source language. Then clone this repository and download the dependencies:
## 🏗️ Installation

Clone this repository:

git clone https://github.com/phpbb/phpbb-translation-validator.git

Install the dependencies with Composer:

composer.phar install

For the easiest results, create a directory called `4.0` in the root of the Translation Validator. Upload the `en` language page into this directory, along with the languages you wish to test. Which leads e.g. to:
Create a directory called `4.0` in the root of the Translation Validator. Afterwards download
the [British English language pack](http://www.phpbb.com/customise/db/translation/british_english/)
and put its content into ``4.0/en/``. Do the same with the languages you wish to test. Which leads e.g. to:

phpbb-translation-validator/4.0/en/
phpbb-translation-validator/4.0/de/
phpbb-translation-validator/4.0/fr/
phpbb-translation-validator/translation.php

The simplest way to validate is to then run this command (the final argument is the language you wish to test and that has already been uploaded to the `3.2` directory; eg. `fr` for French):
## ⚗️ Validate language packs

The simplest way to validate this language packages,
is to open a command line tool in the validator directory.
Then run this command (the final argument is the language you wish to test and that has already been stored to the `4.0` directory; e.g. `fr` for French):

php translation.php validate fr

There are more arguments that can be supplied. For example, suppose you wanted to have your `3.2` directory in a different location, you wanted to explicitly specify phpBB version 3.2 (default validation is against 3.3), you wanted to run in safe mode and you wanted to see all notices displayed - you would run this command:
There are more arguments that can be supplied. For example, suppose you wanted to have your `4.x` directory in a different location, you wanted to explicitly specify phpBB version 4.x (default validation is against 4.0), you wanted to run in safe mode and you wanted to see all notices displayed - you would run this command:

php translation.php validate fr
--package-dir=/path/to/your/4.0
--phpbb-version=4.0
--safe-mode
--display-notices

The `--safe-mode` flag indicates that you want to parse files instead of directly including them. This is useful if you want to run validations on a web server.
The `--safe-mode` flag indicates that you want to parse files instead of directly including them.
This is useful if you want to run validations on a web server.

If you are missing the English language files for the official Viglink extension, they can be easily donwloaded using this command:
If you are missing the English language files for the official Viglink extension,
they can be easily donwloaded using this command:

php translation.php download --files=phpbb-extensions/viglink --phpbb-version=4.0

## Tests

![GitHub Actions CI](https://github.com/phpbb/phpbb-translation-validator/actions/workflows/phpunit.yaml/badge.svg?branch=master)
## 🛠️ Integration to your Repository

In your project you can add phpBB Translation Validator as a dependency:

Expand All @@ -53,18 +68,24 @@ Then add a `php vendor/bin/translation.php` call to your workflow.

We use GitHub Actions as a continuous integration server and phpunit for our unit testing.

### 🏠 Local phpunit execution

To run the unit tests locally, use this command:

php vendor/phpunit/phpunit/phpunit tests/

## Contributing
## 🤖 Tests

![GitHub Actions CI](https://github.com/phpbb/phpbb-translation-validator/actions/workflows/phpunit.yaml/badge.svg?branch=master)

## 🧑‍💻 Contributing

If you notice any problems with this application, please raise an issue at https://github.com/phpbb/phpbb-translation-validator/issues.
If you notice any problems with this application, please raise an issue at the [Github-Repository](https://github.com/phpbb/phpbb-translation-validator/issues).

To submit your own code contributions, please fork the project and submit a pull request at https://github.com/phpbb/phpbb-translation-validator/pulls.
To submit your own code contributions, please fork the project and submit a pull request at [Github-Repository](https://github.com/phpbb/phpbb-translation-validator/pulls).

When a new version is released, the version number will be updated in `composer.json` and `translation.php`. A new tag will be created and the package will become available at https://packagist.org/packages/phpbb/translation-validator.
When a new version is released, the version number will be updated in `composer.json` and `translation.php`. A new tag will be created and the package will become available at [Packagist](https://packagist.org/packages/phpbb/translation-validator).

## License
## 📜 License

[GPLv2](license.txt)
[GNU General Public License v2](license.txt)
3 changes: 1 addition & 2 deletions src/Phpbb/TranslationValidator/Command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ protected function configure()
->setName('download')
->setDescription('If you are missing important files, this tool can automatically download them for you.')
->addOption('files', null, InputOption::VALUE_REQUIRED, 'Which files do you want to download?', 'phpbb-extensions/viglink')
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB version you use to validate against', '3.3');
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB version you use to validate against', '4.0');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$files = $input->getOption('files');
Expand Down
6 changes: 3 additions & 3 deletions src/Phpbb/TranslationValidator/Command/ValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function configure()
->setName('validate')
->setDescription('Run the validator on your language pack.')
->addArgument('origin-iso', InputArgument::REQUIRED, 'The ISO of the language to validate')
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against', '3.3')
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against', '4.0')
->addOption('source-iso', null, InputOption::VALUE_OPTIONAL, 'The ISO of the language to validate against', 'en')
->addOption('package-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language packages', null)
->addOption('language-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language folders', null)
Expand All @@ -52,9 +52,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$displayNotices = $input->getOption('display-notices');
$safeMode = $input->getOption('safe-mode');

if (!in_array($phpbbVersion, array('3.2', '3.3')))
if ($phpbbVersion != '4.0')
{
throw new \RuntimeException('Invalid phpbb-version, allowed versions: 3.2 and 3.3');
throw new \RuntimeException('Invalid phpbb-version, allowed versions: 4.0');
}

$output = new Output($output, $debug);
Expand Down
18 changes: 7 additions & 11 deletions src/Phpbb/TranslationValidator/Validator/FileListValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,21 @@ public function validate()
$sourceFiles[] = $this->sourceLanguagePath . 'LICENSE';
$sourceFiles = array_unique($sourceFiles);

// Get $lang['direction'] of translation to allow additional rtl-files for rtl-translations
$filePath = $this->originPath . '/' . $this->originLanguagePath . 'common.php';
// Get extra->direction from composer.json to allow additional rtl-files for rtl-translations
$filePath = $this->originPath . '/' . $this->originLanguagePath . 'composer.json';

// Safe mode for safe execution on a server
if ($this->safeMode)
{
$lang = ValidatorRunner::langParser($filePath);
$jsonContent = self::langParser($filePath);
}

else
{
include($filePath);
$fileContents = (string) file_get_contents($filePath);
$jsonContent = json_decode($fileContents, true);
}

$this->direction = $lang['DIRECTION'];
$this->direction = $jsonContent['extra']['direction'];
// Throw error, if invalid direction is used
if (!in_array($this->direction, array('rtl', 'ltr')))
{
Expand All @@ -159,7 +160,6 @@ public function validate()

$originFiles = $this->getFileList($this->originPath);

$missingSubsilver2Files = $availableSubsilver2Files = array();
$validFiles = array();
foreach ($sourceFiles as $sourceFile)
{
Expand Down Expand Up @@ -194,10 +194,6 @@ public function validate()
{
$level = Output::NOTICE;
}
else if ($this->phpbbVersion === '3.2' && strpos($origin_file, 'styles/subsilver2/') === 0)
{
$level = Output::FATAL;
}
else if (in_array(substr($origin_file, -4), array('.gif', '.png')) && $this->direction === 'rtl')
{
$level = Output::WARNING;
Expand Down
Loading