[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] com phd: Add a tool for checking language files: util/check-langs.php
From: Maciej Sobaczewski <sobak () php ! net>
Date: 2016-12-18 23:19:44
Message-ID: php-mail-200528c28d076231771ad46e145ceb44628612847 () git ! php ! net
[Download RAW message or body]
Commit: f9c3469776cdf536f194866e4ea55b14c309aeaf
Author: Sobak <msobaczewski@gmail.com> Mon, 19 Dec 2016 00:19:44 +0100
Parents: 4cfcf63b2ba31dddb1a0e331c7bc8935a6058772
Branches: master
Link: http://git.php.net/?p=phd.git;a=commitdiff;h=f9c3469776cdf536f194866e4ea55b14c309aeaf
Log:
Add a tool for checking language files
Changed paths:
A util/check-langs.php
Diff:
diff --git a/util/check-langs.php b/util/check-langs.php
new file mode 100644
index 0000000..979f0d2
--- /dev/null
+++ b/util/check-langs.php
@@ -0,0 +1,53 @@
+<?php
+if ($argc != 2 || (isset($argv[1]) && in_array($argv[1], array('--help', '-h')))) {
+ echo "Check language files for missing/redundant keys\n\n";
+ echo "Usage: {$argv[0]} <lang>\n";
+ echo "Alternative usage: {$argv[0]} all\n";
+ exit;
+}
+
+chdir('../phpdotnet/phd/data/langs/');
+
+if ($argv[1] === 'all') {
+ $languages = glob('*.ini');
+ unset($languages[array_search('en.ini', $languages)]);
+} else {
+ $languages[] = $argv[1] . '.ini';
+}
+
+$englishKeys = array_keys(parse_ini_file('en.ini'));
+
+foreach($languages as $language) {
+ check_language($language, $englishKeys);
+}
+
+function check_language($path, $englishKeys) {
+ $language = substr($path, 0, -4);
+
+ if (!file_exists($path)) {
+ exit("Unknown language: $language\n");
+ }
+
+ $languageKeys = array_keys(parse_ini_file($path));
+
+ $missing = array_diff($englishKeys, $languageKeys);
+ $redundant = array_diff($languageKeys, $englishKeys);
+
+ echo "Checking $language...";
+
+ if (!$missing && !$redundant) {
+ echo " OK\n";
+ }
+
+ if ($missing) {
+ $missing = implode(", ", $missing);
+ echo "\n\tMissing: $missing\n";
+ }
+
+ if ($redundant) {
+ $placing = $missing ? "\t" : "\n\t";
+
+ $redundant = implode(", ", $redundant);
+ echo "{$placing}Redundant: $redundant\n";
+ }
+}
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic