[med-svn] r610 - in trunk/community/website: . inc locale locale/it_IT/LC_MESSAGES
hanska-guest at alioth.debian.org
hanska-guest at alioth.debian.org
Fri Oct 5 16:10:12 UTC 2007
Author: hanska-guest
Date: 2007-10-05 16:10:12 +0000 (Fri, 05 Oct 2007)
New Revision: 610
Added:
trunk/community/website/inc/po-stats.inc.php
trunk/community/website/locales.php
Removed:
trunk/community/website/add_locale.php
trunk/community/website/locale/en_US/
Modified:
trunk/community/website/index.php
trunk/community/website/locale/it_IT/LC_MESSAGES/messages.mo
trunk/community/website/locale/it_IT/LC_MESSAGES/messages.po
trunk/community/website/locale/messages.pot
Log:
Localization statistics; enjoy!
Deleted: trunk/community/website/add_locale.php
===================================================================
--- trunk/community/website/add_locale.php 2007-10-05 11:20:25 UTC (rev 609)
+++ trunk/community/website/add_locale.php 2007-10-05 16:10:12 UTC (rev 610)
@@ -1,33 +0,0 @@
-<?php
- require_once("inc/header.inc.php");
-?>
-<table class="columns">
-<tr>
- <td class="left">
- <span class="section"><?=_("summary")?></span>
- <div class="section">
- <div class="sectionTop"></div>
- <div class="row">
- <?=_("Current locale")?>:
- <strong><?=$locale?></strong>
- </div>
- <div class="row">
- <?=_("Priority")?>:
- <strong><?=$priority?></strong>
- </div>
- </div>
- </td>
- <td class="main">
- <span class="section"><?=_("localization")?></span>
- <div class="section">
- <div class="sectiontop"></div>
- <div class="row">
- <h1><?=_("Add new locale")?></h1>
- </div>
- </div>
- </td>
-</tr>
-</table>
-<?php
- require_once("inc/footer.inc.php");
-?>
Added: trunk/community/website/inc/po-stats.inc.php
===================================================================
--- trunk/community/website/inc/po-stats.inc.php (rev 0)
+++ trunk/community/website/inc/po-stats.inc.php 2007-10-05 16:10:12 UTC (rev 610)
@@ -0,0 +1,118 @@
+<?php
+
+function getCleanPO($po) {
+ global $author, $team;
+
+ $fp = fopen($po, "r");
+ if ($fp) {
+ while (!feof($fp)) {
+ $data .= fgets($fp, 4096);
+ }
+ fclose($fp);
+ }
+
+ // I don't wanna go crazy with regexes now. Yes, they might be simpler though.
+ $regex = "/^\"Last-Translator: (\w+.*<.*@.*>)/m";
+ preg_match($regex, $data, $matches);
+ $author = $matches[1];
+
+ $regex = "/^\"Language-Team: (\w+.*<.*@.*>)/m";
+ preg_match($regex, $data, $matches);
+ $team = $matches[1];
+
+
+ $arr = explode("#:", $data);
+ array_shift($arr);
+
+ for ($i = 0; $i < count($arr); $i++) {
+ $regex = "/^\\#.*\\n/m";
+ $arr[$i] = preg_replace($regex, "", $arr[$i]);
+
+ $regex = "/.*\.php:\d+.*\n/";
+ $arr[$i] = preg_replace($regex, "", $arr[$i]);
+
+ $regex = "/\n$/";
+ $arr[$i] = preg_replace($regex, "", $arr[$i]);
+
+ $arr[$i] = explode("\n", $arr[$i]);
+
+ for ($k = 0; $k < count($arr[$i]); $k++) {
+ preg_match("/(\w+) \"/", $arr[$i][$k], $matches);
+
+ if (($matches[1] != "msgid" && $matches[1] != "msgstr") || !$matches[1]) {
+ $regex = "/(\w+.*\"\")/";
+ preg_match($regex, $arr[$i][$k - 1], $submatch);
+ if ($submatch[1]) {
+ $arr[$i][$k - 1] = substr($submatch[1], 0, strlen($submatch[1]) - 1)."foo\"";
+ } else {
+ $arr[$i][$k] = null;
+ }
+ }
+ }
+ }
+
+ return clean($arr);
+}
+
+function clean($item) {
+ if (is_array ($item)) {
+ if (!count($item)) {
+ $item = null;
+ } else {
+ foreach ($item as $key => $value) {
+ $item[$key] = clean($value);
+ if (empty($item[$key]))
+ unset($item[$key]);
+ }
+ }
+ } else {
+ if (empty($item))
+ $item = null;
+ else {
+ $regex = "/(\w+).*\"/";
+ preg_match($regex, $item, $matches);
+ if ($matches[1] != "msgid" && $matches[1] != "msgstr")
+ $item = null;
+ }
+ }
+
+ return $item;
+}
+
+function makePOStats($po) {
+ global $author, $team;
+
+ $pairs = getCleanPO($po);
+
+ $count = 0;
+ $untranslated = 0;
+ $empty_msgid = false;
+
+ foreach($pairs as $item) {
+ $regex = "/(\w+).*\"(.*)\"/";
+
+ sort($item);
+
+ preg_match($regex, $item[0], $matches);
+ if (!trim($matches[2])) {
+ // this is just a fallback
+ $empty_msgid = true;
+ }
+
+ preg_match($regex, $item[1], $matches);
+ if (!$empty_msgid && !trim($matches[2])) {
+ $untranslated++;
+ }
+
+ $empty_msgid = false;
+ $count++;
+ }
+
+ return array("count" => $count,
+ "missing" => $untranslated,
+ "complete" => 100 - (($untranslated / $count) * 100),
+ "author" => $author,
+ "team" => $team,
+ );
+}
+?>
Property changes on: trunk/community/website/inc/po-stats.inc.php
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/community/website/index.php
===================================================================
--- trunk/community/website/index.php 2007-10-05 11:20:25 UTC (rev 609)
+++ trunk/community/website/index.php 2007-10-05 16:10:12 UTC (rev 610)
@@ -67,8 +67,8 @@
<div class="sectionTop"></div>
<div class="row">
<ul>
- <li><a href="/bugs.php"><?=_("Bugs Page")?></a></li>
- <li><a href="/add_locale.php"><?=_("Add locale")?></a></li>
+ <li><a href="/bugs.php"><?=_("Bugs page")?></a></li>
+ <li><a href="/add_locale.php"><?=_("Locales page")?></a></li>
<li>…</li>
</ul>
</div>
Modified: trunk/community/website/locale/it_IT/LC_MESSAGES/messages.mo
===================================================================
(Binary files differ)
Modified: trunk/community/website/locale/it_IT/LC_MESSAGES/messages.po
===================================================================
--- trunk/community/website/locale/it_IT/LC_MESSAGES/messages.po 2007-10-05 11:20:25 UTC (rev 609)
+++ trunk/community/website/locale/it_IT/LC_MESSAGES/messages.po 2007-10-05 16:10:12 UTC (rev 610)
@@ -3,7 +3,7 @@
# This file is distributed under the GNU General Public License v2+.
# David Paleino <d.paleino at gmail.com>, 2007.
#
-#, fuzzy
+#,fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
@@ -105,12 +105,12 @@
msgstr "pagine"
#: index.php:70
-msgid "Bugs Page"
+msgid "Bugs page"
msgstr "Pagina Bugs"
#: index.php:71
-msgid "Add locale"
-msgstr ""
+msgid "Locales page"
+msgstr "Pagina locales"
#: index.php:76
msgid "UTC time"
Modified: trunk/community/website/locale/messages.pot
===================================================================
--- trunk/community/website/locale/messages.pot 2007-10-05 11:20:25 UTC (rev 609)
+++ trunk/community/website/locale/messages.pot 2007-10-05 16:10:12 UTC (rev 610)
@@ -100,11 +100,11 @@
msgstr ""
#: index.php:70
-msgid "Bugs Page"
+msgid "Bugs page"
msgstr ""
#: index.php:71
-msgid "Add locale"
+msgid "Locales page"
msgstr ""
#: index.php:76
Added: trunk/community/website/locales.php
===================================================================
--- trunk/community/website/locales.php (rev 0)
+++ trunk/community/website/locales.php 2007-10-05 16:10:12 UTC (rev 610)
@@ -0,0 +1,88 @@
+<?php
+ require_once("inc/header.inc.php");
+?>
+<table class="columns">
+<tr>
+ <td class="left">
+ <span class="section"><?=_("summary")?></span>
+ <div class="section">
+ <div class="sectionTop"></div>
+ <div class="row">
+ <?=_("Current locale")?>:
+ <strong><?=$locale?></strong>
+ </div>
+ <div class="row">
+ <?=_("Priority")?>:
+ <strong><?=$priority?></strong>
+ </div>
+ <?php
+ if ($show_locale_warning) {
+ ?>
+ <div class="row warning">
+ <?=_("You're using a low priority locale.<br />Please ask the site administrators to add your locale, or provide one yourself :).<br />")?>
+ <?=_("More information on how to contribute to the Debian-Med project, can be found in the")?>
+ <a href="/contribute.php"><del><?=_("How to Contribute")?></del></a><?=_("page")?>.
+ </div>
+ <?php
+ }
+ ?>
+ </div>
+ </td>
+ <td class="main">
+ <span class="section"><?=_("localization")?></span>
+ <div class="section">
+ <div class="sectiontop"></div>
+ <div class="row">
+ <h1><?=_("Currently installed locales")?></h1>
+ <table>
+ <tr>
+ <th><?=_("locale")?></th>
+ <th><?=_("translation status")?></th>
+ <th><?=_("author")?></th>
+ <th><?=_("team")?></th>
+ </tr>
+ <tr>
+ <td><strong>en_US</strong></td>
+ <td>100% (builtin)</td>
+ <td></td>
+ <td></td>
+ </tr>
+ <?php
+ require_once("inc/po-stats.inc.php");
+
+ $handle = opendir("locale/");
+ $avail_locales = array();
+ while ($file = readdir($handle)) {
+ if ($file != "." && $file != ".." && $file != ".svn") {
+ // we get this $locales_dir from locale.inc.php
+ //if (is_dir($locales_dir.$file)) {
+ if (is_dir("locale/$file")) {
+ $po = "locale/$file/LC_MESSAGES/messages.po";
+ $avail_locales[$file] = makePOStats($po);
+ }
+ }
+ }
+
+ foreach ($avail_locales as $lang) {
+ ?>
+ <tr>
+ <td><strong><?=key($avail_locales)?><strong></td>
+ <td><?=$lang["complete"]?>%</td>
+ <td><?=htmlentities($lang["author"])?></td>
+ <td><?=htmlentities($lang["team"])?></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </div>
+ <div class="row">
+ <h1><?=_("Add new locale")?></h1>
+ </div>
+ </div>
+ </td>
+</tr>
+</table>
+<?php
+ require_once("inc/footer.inc.php");
+?>
More information about the debian-med-commit
mailing list