From 26a4a09c111fec9edf0ebb680627720a1ce1cedd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 5 Apr 2011 15:28:02 +0200 Subject: [PATCH] Display warning about incomplete translations --- Documentation.html | 3 +++ libraries/.gitignore | 1 + libraries/config.default.php | 7 +++++++ main.php | 17 +++++++++++++++++ scripts/remove-incomplete-mo | 9 +++++++++ 5 files changed, 37 insertions(+) create mode 100644 libraries/.gitignore diff --git a/Documentation.html b/Documentation.html index af3c44bd8..baa3d1e8c 100644 --- a/Documentation.html +++ b/Documentation.html @@ -624,6 +624,9 @@ since this link provides funding for phpMyAdmin. You can set this parameter to TRUE to stop this message from appearing. +
$cfg['TranslationWarningThreshold'] integer +
Show warning about incomplete translations on certain threshold.
+
$cfg['AllowThirdPartyFraming'] boolean
Setting this to true allows a page located on a different domain to call phpMyAdmin inside a frame, and is a potential security diff --git a/libraries/.gitignore b/libraries/.gitignore new file mode 100644 index 000000000..ea4a1fdaf --- /dev/null +++ b/libraries/.gitignore @@ -0,0 +1 @@ +language_stats.inc.php diff --git a/libraries/config.default.php b/libraries/config.default.php index d47b705bd..4ca31e78f 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -62,6 +62,13 @@ $cfg['SuhosinDisableWarning'] = false; $cfg['McryptDisableWarning'] = false; /** + * Show warning about incomplete translations on certain threshold. + * + * @global boolean $cfg['TranslationWarningThreshold'] + */ +$cfg['TranslationWarningThreshold'] = 80; + +/** * Allows phpMyAdmin to be included from a document located on * another domain; setting this to true is a potential security hole * diff --git a/main.php b/main.php index 431f65b87..7a912429f 100644 --- a/main.php +++ b/main.php @@ -355,6 +355,23 @@ if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_valu } /** + * Warning about incomplete translations. + * + * The data file is created while creating release by ./scripts/remove-incomplete-mo + */ +if (file_exists('./libraries/language_stats.inc.php')) { + include('./libraries/language_stats.inc.php'); + /* + * This message is intentionally not translated, because we're + * handling incomplete translations here and focus on english + * speaking users. + */ + if (isset($GLOBALS['language_stats'][$lang]) && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']) { + trigger_error('You are using translation which is not complete, you are welcome to contribute to it.', E_USER_NOTICE); + } +} + +/** * prints list item for main page * * @param string $name displayed text diff --git a/scripts/remove-incomplete-mo b/scripts/remove-incomplete-mo index 65b5ad488..a9ff4eb94 100755 --- a/scripts/remove-incomplete-mo +++ b/scripts/remove-incomplete-mo @@ -14,6 +14,12 @@ if [ ! -z "$1" ] ; then THRESHOLD=$1 fi +echo ' libraries/language_stats.inc.php +echo '/* Automatically generated file, do not edit! */' >> libraries/language_stats.inc.php +echo '/* Generated bt scripts/remove-incomplete-mo */' >> libraries/language_stats.inc.php +echo '' >> libraries/language_stats.inc.php +echo '$GLOBALS["language_stats"] = array (' >> libraries/language_stats.inc.php + check() { lang=`echo $1 | sed 's@po/\(.*\)\.po@\1@'` STATS=`LANG=C msgfmt --statistics -o /dev/null $1 2>&1` @@ -33,6 +39,7 @@ check() { UNTRANSLATED=0 fi PERCENT=`expr 100 \* $TRANSLATED / \( $TRANSLATED + $FUZZY + $UNTRANSLATED \) || true` + echo " '$lang' => $PERCENT," >> libraries/language_stats.inc.php if [ $PERCENT -lt $THRESHOLD ] ; then echo "Removing $lang, only $PERCENT%" @@ -44,3 +51,5 @@ for x in po/*.po ; do check $x done +echo ');' >> libraries/language_stats.inc.php +echo '?>' >> libraries/language_stats.inc.php -- 2.11.4.GIT