Skip to content

Commit 023f992

Browse files
authored
Merge pull request #40 from Crizz0/issue/32
Allows additional images .gif or .png for rtl translations
2 parents a10432e + 1da5e97 commit 023f992

File tree

5 files changed

+199
-1
lines changed

5 files changed

+199
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
/**
15+
* DO NOT CHANGE
16+
*/
17+
if (!defined('IN_PHPBB'))
18+
{
19+
exit;
20+
}
21+
22+
if (empty($lang) || !is_array($lang))
23+
{
24+
$lang = array();
25+
}
26+
27+
// DEVELOPERS PLEASE NOTE
28+
//
29+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
30+
//
31+
// Placeholders can now contain order information, e.g. instead of
32+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
33+
// translators to re-order the output of data while ensuring it remains correct
34+
//
35+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
36+
// equally where a string contains only two placeholders which are used to wrap text
37+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
38+
//
39+
// Some characters you may want to copy&paste:
40+
// ’ » “ ” …
41+
//
42+
43+
$lang = array_merge($lang, array(
44+
'DIRECTION' => 'ltr',
45+
));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
/**
15+
* DO NOT CHANGE
16+
*/
17+
if (!defined('IN_PHPBB'))
18+
{
19+
exit;
20+
}
21+
22+
if (empty($lang) || !is_array($lang))
23+
{
24+
$lang = array();
25+
}
26+
27+
// DEVELOPERS PLEASE NOTE
28+
//
29+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
30+
//
31+
// Placeholders can now contain order information, e.g. instead of
32+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
33+
// translators to re-order the output of data while ensuring it remains correct
34+
//
35+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
36+
// equally where a string contains only two placeholders which are used to wrap text
37+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
38+
//
39+
// Some characters you may want to copy&paste:
40+
// ’ » “ ” …
41+
//
42+
43+
$lang = array_merge($lang, array(
44+
'DIRECTION' => 'ltr',
45+
));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
/**
15+
* DO NOT CHANGE
16+
*/
17+
if (!defined('IN_PHPBB'))
18+
{
19+
exit;
20+
}
21+
22+
if (empty($lang) || !is_array($lang))
23+
{
24+
$lang = array();
25+
}
26+
27+
// DEVELOPERS PLEASE NOTE
28+
//
29+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
30+
//
31+
// Placeholders can now contain order information, e.g. instead of
32+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
33+
// translators to re-order the output of data while ensuring it remains correct
34+
//
35+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
36+
// equally where a string contains only two placeholders which are used to wrap text
37+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
38+
//
39+
// Some characters you may want to copy&paste:
40+
// ’ » “ ” …
41+
//
42+
43+
$lang = array_merge($lang, array(
44+
'DIRECTION' => 'ltr',
45+
));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
/**
15+
* DO NOT CHANGE
16+
*/
17+
if (!defined('IN_PHPBB'))
18+
{
19+
exit;
20+
}
21+
22+
if (empty($lang) || !is_array($lang))
23+
{
24+
$lang = array();
25+
}
26+
27+
// DEVELOPERS PLEASE NOTE
28+
//
29+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
30+
//
31+
// Placeholders can now contain order information, e.g. instead of
32+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
33+
// translators to re-order the output of data while ensuring it remains correct
34+
//
35+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
36+
// equally where a string contains only two placeholders which are used to wrap text
37+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
38+
//
39+
// Some characters you may want to copy&paste:
40+
// ’ » “ ” …
41+
//
42+
43+
$lang = array_merge($lang, array(
44+
'DIRECTION' => 'ltr',
45+
));

src/Phpbb/TranslationValidator/Validator/FileListValidator.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ public function validate()
120120
$sourceFiles[] = $this->sourceLanguagePath . 'LICENSE';
121121
$sourceFiles = array_unique($sourceFiles);
122122

123+
//Get $lang['direction'] of translation to allow additional rtl-files for rtl-translations
124+
include($this->originPath . '/' . $this->originLanguagePath . 'common.php');
125+
$direction = $lang['DIRECTION'];
126+
// Throw error, if invalid direction is used
127+
if (!in_array($direction, array('rtl', 'ltr')))
128+
{
129+
$this->output->addMessage(Output::FATAL, 'DIRECTION needs to be rtl or ltr');
130+
}
131+
123132
$originFiles = $this->getFileList($this->originPath);
124133

125134
$missingSubsilver2Files = $availableSubsilver2Files = array();
@@ -195,10 +204,19 @@ public function validate()
195204
{
196205
$level = Output::FATAL;
197206
}
207+
else if (in_array(substr($origin_file, -4), array('.gif', '.png')) && $direction === 'rtl')
208+
{
209+
$level = Output::WARNING;
210+
}
211+
else if (substr($origin_file, -3) !== '.md')
212+
{
213+
$level = Output::FATAL;
214+
}
198215
else
199216
{
200-
$level = (substr($origin_file, -3) !== '.md') ? Output::FATAL : Output::ERROR;
217+
$level = Output::ERROR;
201218
}
219+
202220
$this->output->addMessage($level, 'Found additional file', $origin_file);
203221
}
204222

0 commit comments

Comments
 (0)