Skip to content

Commit 30527eb

Browse files
committed
Integrate translation update script
1 parent 00c42d8 commit 30527eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1410
-112
lines changed

src/Resources/bin/update-translations.php renamed to bin/update-translations

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
#!/usr/bin/env php
12
<?php
23

4+
/*
5+
* Symfony DataTables Bundle
6+
* (c) Omines Internetbureau B.V. - https://omines.nl/
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
314
use Symfony\Component\Intl\Locales;
415
use Symfony\Component\Yaml\Yaml;
516

6-
require_once __DIR__.'/autoload.php';
17+
define('RESOURCE_PATH', dirname(__DIR__) . '/src/Resources');
18+
19+
$autoload = __DIR__ . '/../vendor/autoload.php';
20+
if (!file_exists($autoload)) {
21+
echo 'You should run "composer install" in the library root before running this script.';
22+
}
23+
require_once $autoload;
724

825
$argc = $_SERVER['argc'];
926
$argv = $_SERVER['argv'];
1027

11-
if ($argc !== 2 || in_array($argv[1], ['-h', '--help'])) {
28+
if (2 !== $argc || in_array($argv[1], ['-h', '--help'], true)) {
1229
echo '
13-
Usage: php update-translations.php <version>
30+
Usage: bin/update-translations <version>
1431
1532
Updates the translations messages data from https://github.com/DataTables/Plugins
1633
@@ -28,23 +45,29 @@
2845
$tempZipFile = downloadToTempFile($zipUrl);
2946

3047
traverseLangFilesInZip($tempZipFile, function ($filename, $content) {
31-
$langData = json_decode(substr($content, strpos($content, '{')), true);
48+
$langData = json_decode(mb_substr($content, mb_strpos($content, '{')), true);
3249
if (!is_array($langData)) {
3350
printf("JSON error '%s' in %s\n", json_last_error_msg(), $filename);
51+
3452
return;
3553
}
3654

37-
// change keys like sEmptyTable to emptyTable
38-
$langData = normalizeArrayKeys($langData);
55+
// Change keys like sEmptyTable to emptyTable
56+
try {
57+
$langData = normalizeArrayKeys($langData);
3958

40-
$localeName = getLocaleNameFromLangFilename($filename);
41-
$locale = getLocaleByName($localeName);
42-
if ($locale === false) {
43-
printf("Unsupported locale name '%s'\n", $localeName);
44-
return;
45-
}
59+
$localeName = getLocaleNameFromLangFilename($filename);
60+
$locale = getLocaleByName($localeName);
61+
if (false === $locale) {
62+
printf("Unsupported locale name '%s'\n", $localeName);
63+
64+
return;
65+
}
4666

47-
updateMessagesFileWithLangData($locale, $langData);
67+
updateMessagesFileWithLangData($locale, $langData);
68+
} catch (\Error $e) {
69+
printf("Could not parse source file '%s'\n", $filename);
70+
}
4871
});
4972

5073
unlink($tempZipFile);
@@ -74,13 +97,13 @@ function downloadToTempFile(string $url): string
7497

7598
function traverseLangFilesInZip(string $zipFile, callable $function)
7699
{
77-
$zip = new ZipArchive;
78-
if ($zip->open($zipFile) !== true) {
100+
$zip = new ZipArchive();
101+
if (true !== $zip->open($zipFile)) {
79102
throw new \RuntimeException(sprintf('Failed opening "%s"', $zipFile));
80103
}
81104

82105
// loop to find lang files
83-
for ($i = 0; $i < $zip->numFiles; $i++) {
106+
for ($i = 0; $i < $zip->numFiles; ++$i) {
84107
$filename = $zip->getNameIndex($i);
85108
if (preg_match('#/i18n/.*\.lang#', $filename)) {
86109
$content = $zip->getFromIndex($i);
@@ -95,8 +118,8 @@ function normalizeArrayKeys(array $input): array
95118
{
96119
$output = [];
97120
foreach ($input as $key => $value) {
98-
if (strpos($key, 's') === 0 || strpos($key, 'o') === 0) {
99-
$key = lcfirst(substr($key, 1));
121+
if (0 === mb_strpos($key, 's') || 0 === mb_strpos($key, 'o')) {
122+
$key = lcfirst(mb_substr($key, 1));
100123
}
101124

102125
if (is_array($value)) {
@@ -111,7 +134,7 @@ function normalizeArrayKeys(array $input): array
111134

112135
function updateMessagesFileWithLangData(string $locale, array $langData): bool
113136
{
114-
$messageFile = sprintf('%s/translations/messages.%s.yml', dirname(__DIR__), $locale);
137+
$messageFile = sprintf('%s/translations/messages.%s.yml', RESOURCE_PATH, $locale);
115138

116139
$messages = [
117140
'datatable' => [
@@ -129,7 +152,8 @@ function updateMessagesFileWithLangData(string $locale, array $langData): bool
129152
$messages = array_replace_recursive($messages, ['datatable' => ['datatable' => $langData]]);
130153

131154
printf("Updating messages for %s\n", $locale);
132-
return file_put_contents($messageFile, Yaml::dump($messages, 4, 4, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE));
155+
156+
return (bool) file_put_contents($messageFile, Yaml::dump($messages, 4, 4, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE));
133157
}
134158

135159
function getLocaleNameFromLangFilename($filename)

src/Resources/bin/autoload.php

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
emptyTable: 'Geen data beskikbaar in tabel'
6+
info: 'uitstalling _START_ to _END_ of _TOTAL_ inskrywings'
7+
infoEmpty: 'uitstalling 0 to 0 of 0 inskrywings'
8+
infoFiltered: '(gefiltreer uit _MAX_ totaal inskrywings)'
9+
infoPostFix: ''
10+
infoThousands: ','
11+
lengthMenu: 'uitstal _MENU_ inskrywings'
12+
loadingRecords: laai...
13+
processing: verwerking...
14+
search: 'soektog:'
15+
zeroRecords: 'Geen treffers gevind'
16+
paginate:
17+
first: eerste
18+
last: laaste
19+
next: volgende
20+
previous: vorige
21+
aria:
22+
sortAscending: ': aktiveer kolom stygende te sorteer'
23+
sortDescending: ': aktiveer kolom orde te sorteer'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
emptyTable: 'ባዶ ሰንጠረዥ'
6+
info: 'ከጠቅላላው _TOTAL_ ዝርዝሮች ውስጥ ከ _START_ እስከ _END_ ያሉት ዝርዝር'
7+
infoEmpty: 'ከጠቅላላው 0 ዝርዝሮች ውስጥ ከ 0 እስከ 0 ያሉት ዝርዝር'
8+
infoFiltered: '(ከጠቅላላው _MAX_ የተመረጡ ዝርዝሮች)'
9+
infoPostFix: ''
10+
infoThousands: ','
11+
lengthMenu: 'የዝርዝሮች ብዛት _MENU_'
12+
loadingRecords: 'በማቅረብ ላይ...'
13+
processing: 'በማቀናበር ላይ...'
14+
search: 'ፈልግ:'
15+
zeroRecords: 'ከሚፈለገው ጋር የሚሚሳሰል ዝርዝር አልተገኘም'
16+
paginate:
17+
first: መጀመሪያ
18+
last: መጨረሻ
19+
next: ቀጣዩ
20+
previous: የበፊቱ
21+
aria:
22+
sortAscending: ': ከመጀመሪያ ወደ መጨረሻ(ወጪ) አደራደር'
23+
sortDescending: ': ከመጨረሻ ወደ መጀመሪያ(ወራጅ) አደራደር'

src/Resources/translations/messages.ar.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ datatable:
22
common:
33
are_you_sure: 'هل أنت متأكد ؟'
44
you_need_to_select_at_least_one_element: 'تحتاج إلى تحديد عنصر واحد على الأقل.'
5-
search: 'بحث'
5+
search: بحث
66
execute: تنفيذ
77
ok: حسنا
88
datatable:
9-
searchPlaceholder: ""
10-
processing: "جاري التحميل..."
11-
lengthMenu: "أظهر مُدخلات _MENU_"
12-
zeroRecords: "لم يُعثر على أية سجلات"
13-
info: "إظهار _START_ إلى _END_ من أصل _TOTAL_ مُدخل"
14-
infoEmpty: "يعرض 0 إلى 0 من أصل 0 سجلّ"
15-
infoFiltered: "(منتقاة من مجموع _MAX_ مُدخل)"
16-
infoPostFix: ""
17-
search: "ابحث:"
9+
searchPlaceholder: ''
10+
processing: 'جارٍ التحميل...'
11+
lengthMenu: 'أظهر _MENU_ مدخلات'
12+
zeroRecords: 'لم يعثر على أية سجلات'
13+
info: 'إظهار _START_ إلى _END_ من أصل _TOTAL_ مدخل'
14+
infoEmpty: 'يعرض 0 إلى 0 من أصل 0 سجل'
15+
infoFiltered: '(منتقاة من مجموع _MAX_ مُدخل)'
16+
infoPostFix: ''
17+
search: 'ابحث:'
1818
paginate:
19-
first: "الأول"
20-
previous: "السابق"
21-
next: "التالي"
22-
last: "الأخير"
19+
first: الأول
20+
previous: السابق
21+
next: التالي
22+
last: الأخير
2323
aria:
24-
sortAscending: "تفعيل لفرز العمود تصاعدي"
25-
sortDescending: "تفعيل لفرز العمود الهابطة"
24+
sortAscending: ': تفعيل لترتيب العمود تصاعدياً'
25+
sortDescending: ': تفعيل لترتيب العمود تنازلياً'
26+
emptyTable: 'ليست هناك بيانات متاحة في الجدول'
27+
loadingRecords: 'جارٍ التحميل...'
28+
url: ''
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
emptyTable: 'Cədvəldə heç bir məlumat yoxdur'
6+
info: ' _TOTAL_ Nəticədən _START_ - _END_ Arası Nəticələr'
7+
infoEmpty: 'Nəticə Yoxdur'
8+
infoFiltered: '( _MAX_ Nəticə İçindən Tapılanlar)'
9+
infoPostFix: ''
10+
infoThousands: ','
11+
lengthMenu: 'Səhifədə _MENU_ Nəticə Göstər'
12+
loadingRecords: Yüklənir...
13+
processing: Gözləyin...
14+
search: 'Axtarış:'
15+
zeroRecords: 'Nəticə Tapılmadı.'
16+
paginate:
17+
first: İlk
18+
last: Axırıncı
19+
next: Sonraki
20+
previous: Öncəki
21+
aria:
22+
sortAscending: ': sütunu artma sırası üzərə aktiv etmək'
23+
sortDescending: ': sütunu azalma sırası üzərə aktiv etmək'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
processing: Пачакайце...
6+
lengthMenu: 'Паказваць _MENU_ запісаў'
7+
zeroRecords: 'Запісы адсутнічаюць.'
8+
info: 'Запісы з _START_ па _END_ з _TOTAL_ запісаў'
9+
infoEmpty: 'Запісы з 0 па 0 з 0 запісаў'
10+
infoFiltered: '(адфільтравана з _MAX_ запісаў)'
11+
infoPostFix: ''
12+
search: 'Пошук:'
13+
url: ''
14+
paginate:
15+
first: Першая
16+
previous: Папярэдняя
17+
next: Наступная
18+
last: Апошняя
19+
aria:
20+
sortAscending: ': актываваць для сартавання слупка па ўзрастанні'
21+
sortDescending: ': актываваць для сартавання слупка па змяншэнні'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
processing: 'Обработка на резултатите...'
6+
lengthMenu: 'Показване на _MENU_ резултата'
7+
zeroRecords: 'Няма намерени резултати'
8+
info: 'Показване на резултати от _START_ до _END_ от общо _TOTAL_'
9+
infoEmpty: 'Показване на резултати от 0 до 0 от общо 0'
10+
infoFiltered: '(филтрирани от общо _MAX_ резултата)'
11+
infoPostFix: ''
12+
search: 'Търсене:'
13+
url: ''
14+
paginate:
15+
first: Първа
16+
previous: Предишна
17+
next: Следваща
18+
last: Последна
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
processing: 'প্রসেসিং হচ্ছে...'
6+
lengthMenu: '_MENU_ টা এন্ট্রি দেখাও'
7+
zeroRecords: 'আপনি যা অনুসন্ধান করেছেন তার সাথে মিলে যাওয়া কোন রেকর্ড খুঁজে পাওয়া যায় নাই'
8+
info: '_TOTAL_ টা এন্ট্রির মধ্যে _START_ থেকে _END_ পর্যন্ত দেখানো হচ্ছে'
9+
infoEmpty: 'কোন এন্ট্রি খুঁজে পাওয়া যায় নাই'
10+
infoFiltered: '(মোট _MAX_ টা এন্ট্রির মধ্যে থেকে বাছাইকৃত)'
11+
infoPostFix: ''
12+
search: 'অনুসন্ধান:'
13+
url: ''
14+
paginate:
15+
first: প্রথমটা
16+
previous: আগেরটা
17+
next: পরবর্তীটা
18+
last: শেষেরটা
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
datatable:
2+
common: []
3+
datatable:
4+
searchPlaceholder: ''
5+
processing: Processant...
6+
lengthMenu: 'Mostra _MENU_ registres'
7+
zeroRecords: 'No s''han trobat registres.'
8+
info: 'Mostrant de _START_ a _END_ de _TOTAL_ registres'
9+
infoEmpty: 'Mostrant de 0 a 0 de 0 registres'
10+
infoFiltered: '(filtrat de _MAX_ total registres)'
11+
infoPostFix: ''
12+
search: 'Filtrar:'
13+
url: ''
14+
paginate:
15+
first: Primer
16+
previous: Anterior
17+
next: Següent
18+
last: Últim

0 commit comments

Comments
 (0)