Skip to content

Commit 22c7215

Browse files
authored
Merge pull request #84 from Crizz0/iss/81
Update TLV for phpBB 4
2 parents aae50bd + fe6e927 commit 22c7215

37 files changed

+295
-230
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/vendor/
22
/.idea/
33
/bin/
4-
/3.2/
5-
/3.3/
4+
/4.0/

README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,60 @@
1-
# phpBB Translation Validator - master-dev
1+
# phpBB Translation Validator
22

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

5-
## Requirements
8+
## 📋Requirements
69

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

9-
### Installation
1013

11-
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:
14+
## 🏗️ Installation
15+
16+
Clone this repository:
1217

1318
git clone https://github.com/phpbb/phpbb-translation-validator.git
19+
20+
Install the dependencies with Composer:
21+
1422
composer.phar install
1523

16-
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:
24+
Create a directory called `4.0` in the root of the Translation Validator. Afterwards download
25+
the [British English language pack](http://www.phpbb.com/customise/db/translation/british_english/)
26+
and put its content into ``4.0/en/``. Do the same with the languages you wish to test. Which leads e.g. to:
1727

1828
phpbb-translation-validator/4.0/en/
1929
phpbb-translation-validator/4.0/de/
30+
phpbb-translation-validator/4.0/fr/
2031
phpbb-translation-validator/translation.php
2132

22-
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):
33+
## ⚗️ Validate language packs
34+
35+
The simplest way to validate this language packages,
36+
is to open a command line tool in the validator directory.
37+
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):
2338

2439
php translation.php validate fr
2540

26-
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:
41+
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:
2742

2843
php translation.php validate fr
2944
--package-dir=/path/to/your/4.0
3045
--phpbb-version=4.0
3146
--safe-mode
3247
--display-notices
3348

34-
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.
49+
The `--safe-mode` flag indicates that you want to parse files instead of directly including them.
50+
This is useful if you want to run validations on a web server.
3551

36-
If you are missing the English language files for the official Viglink extension, they can be easily donwloaded using this command:
52+
If you are missing the English language files for the official Viglink extension,
53+
they can be easily donwloaded using this command:
3754

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

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

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

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

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

71+
### 🏠 Local phpunit execution
72+
5673
To run the unit tests locally, use this command:
5774

5875
php vendor/phpunit/phpunit/phpunit tests/
5976

60-
## Contributing
77+
## 🤖 Tests
78+
79+
![GitHub Actions CI](https://github.com/phpbb/phpbb-translation-validator/actions/workflows/phpunit.yaml/badge.svg?branch=master)
80+
81+
## 🧑‍💻 Contributing
6182

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

64-
To submit your own code contributions, please fork the project and submit a pull request at https://github.com/phpbb/phpbb-translation-validator/pulls.
85+
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).
6586

66-
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.
87+
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).
6788

68-
## License
89+
## 📜 License
6990

70-
[GPLv2](license.txt)
91+
[GNU General Public License v2](license.txt)

src/Phpbb/TranslationValidator/Command/DownloadCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ protected function configure()
3131
->setName('download')
3232
->setDescription('If you are missing important files, this tool can automatically download them for you.')
3333
->addOption('files', null, InputOption::VALUE_REQUIRED, 'Which files do you want to download?', 'phpbb-extensions/viglink')
34-
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB version you use to validate against', '3.3');
34+
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB version you use to validate against', '4.0');
3535
}
36-
3736
protected function execute(InputInterface $input, OutputInterface $output)
3837
{
3938
$files = $input->getOption('files');

src/Phpbb/TranslationValidator/Command/ValidateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function configure()
2525
->setName('validate')
2626
->setDescription('Run the validator on your language pack.')
2727
->addArgument('origin-iso', InputArgument::REQUIRED, 'The ISO of the language to validate')
28-
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against', '3.3')
28+
->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against', '4.0')
2929
->addOption('source-iso', null, InputOption::VALUE_OPTIONAL, 'The ISO of the language to validate against', 'en')
3030
->addOption('package-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language packages', null)
3131
->addOption('language-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language folders', null)
@@ -52,9 +52,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
5252
$displayNotices = $input->getOption('display-notices');
5353
$safeMode = $input->getOption('safe-mode');
5454

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

6060
$output = new Output($output, $debug);

src/Phpbb/TranslationValidator/Validator/FileListValidator.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,21 @@ public function validate()
137137
$sourceFiles[] = $this->sourceLanguagePath . 'LICENSE';
138138
$sourceFiles = array_unique($sourceFiles);
139139

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

143+
// Safe mode for safe execution on a server
143144
if ($this->safeMode)
144145
{
145-
$lang = ValidatorRunner::langParser($filePath);
146+
$jsonContent = self::langParser($filePath);
146147
}
147-
148148
else
149149
{
150-
include($filePath);
150+
$fileContents = (string) file_get_contents($filePath);
151+
$jsonContent = json_decode($fileContents, true);
151152
}
152153

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

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

162-
$missingSubsilver2Files = $availableSubsilver2Files = array();
163163
$validFiles = array();
164164
foreach ($sourceFiles as $sourceFile)
165165
{
@@ -194,10 +194,6 @@ public function validate()
194194
{
195195
$level = Output::NOTICE;
196196
}
197-
else if ($this->phpbbVersion === '3.2' && strpos($origin_file, 'styles/subsilver2/') === 0)
198-
{
199-
$level = Output::FATAL;
200-
}
201197
else if (in_array(substr($origin_file, -4), array('.gif', '.png')) && $this->direction === 'rtl')
202198
{
203199
$level = Output::WARNING;

0 commit comments

Comments
 (0)