Esempio n. 1
0
// of the License, or any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//////////////////////////////////////////////////////////////////////////
$relPath = "./../../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'slim_header.inc';
$lang = short_lang_code();
include "{$wikihiero_dir}/wh_language.php";
include "{$wikihiero_dir}/wikihiero.php";
require_login();
$wh_img_url = "{$wikihiero_url}/" . WH_IMG_DIR;
if (array_key_exists("table", $_GET)) {
    $table = $_GET["table"];
} else {
    $table = "";
}
function WH_Text($index)
{
    global $wh_language;
    global $lang;
    if (isset($wh_language[$index])) {
        if (isset($wh_language[$index][$lang])) {
Esempio n. 2
0
function main_form()
{
    // display the list of languages with links to the downloadable PO files
    global $dyn_locales_dir, $translate_url, $may_manage, $allowed_functions;
    $pot_filename = "{$dyn_locales_dir}/messages.pot";
    echo "<h1>" . _("Translation Center") . "</h1>";
    echo "<p>" . _("See the <a href='../../faq/translate.php'>Translation FAQ</a> for more information on how to use this interface to manage translations.") . "</p>";
    if (!$may_manage) {
        echo "<p><em>" . _("You are not a registered translator. You will be able to view the translation interface, but you cannot save a translation or add a new language.") . "</em></p>\n";
    }
    echo "<h2>" . _("Translations") . "</h2>";
    echo "<p>" . _("The following languages are translated or in the process of being translated.") . "</p>";
    if (in_array("newtranslation", $allowed_functions)) {
        if (is_file($pot_filename)) {
            echo "<p> " . sprintf(_("<a href='%s'>Create a new translation.</a>"), "{$translate_url}?func=newtranslation") . "</p>";
        } else {
            echo "<p>" . _("To create a new translation, first generate a new POT file.") . "</p>";
        }
    }
    // PO files for currently existing languages
    echo "<table class='translation'>\n";
    echo "<tr>";
    echo "<th>" . _("Language") . "</th>";
    echo "<th>" . _("Locale") . "</th>";
    echo "<th>" . _("Status") . "</th>";
    echo "<th>" . _("PO file last modified") . "</th>";
    echo "<th>" . _("Translation progress") . "</th>";
    echo "<th>" . _("Actions") . "</th>";
    echo "<th></th>";
    echo "</tr>\n";
    $locale_translations = get_installed_locale_translations();
    $system_locales = get_installed_system_locales();
    foreach ($locale_translations as $locale) {
        $language_name = eng_name(short_lang_code($locale));
        $po_filename = "{$dyn_locales_dir}/{$locale}/LC_MESSAGES/messages.po";
        $translation_enabled = is_locale_translation_enabled($locale);
        echo "<tr>";
        echo "<td>{$language_name}</td>";
        echo "<td>{$locale}</td>";
        if ($translation_enabled) {
            echo "<td>" . _("Enabled") . "</td>";
        } else {
            echo "<td>" . _("Disabled") . "</td>";
        }
        $po_file = new POFile($po_filename);
        if ($po_file->exists) {
            echo "<td>";
            echo date("F d Y H:i:s", $po_file->last_modified);
            echo "</td>";
            echo "<td style='text-align: right'>";
            // TRANSLATORS: This shows the number of strings translated with a percentage
            $total_strings = $po_file->messages_count;
            $translated_strings = $po_file->messages_translated_count;
            if ($total_strings) {
                $percent_translated = $translated_strings / $total_strings * 100;
            } else {
                $percent_translated = 0;
            }
            echo sprintf(_('%1$s of %2$s translated (%3$d%%)'), $translated_strings, $total_strings, $percent_translated);
            echo "</td>";
        } else {
            echo "<td></td>";
            echo "<td></td>";
        }
        echo "<td>";
        $actions = array();
        if ($may_manage) {
            $actions[] = "<a href='{$translate_url}?func=manage&amp;locale={$locale}'>" . _("Manage") . "</a>";
        }
        if ($po_file->exists) {
            $actions[] = "<a href='{$translate_url}?func=view&amp;locale={$locale}'>" . _("View") . "</a>";
            $actions[] = "<a href='{$translate_url}?func=download&amp;locale={$locale}'>" . _("Download") . "</a>";
        }
        echo implode(" | ", $actions);
        echo "</td>";
        if (!in_array($locale, $system_locales)) {
            echo "<td>" . _("Warning: system locale not installed") . "</td>";
        }
        echo "</tr>\n";
    }
    echo "</table>\n";
    echo "<h2>" . _("PO Template") . "</h2>";
    $pot_file = new POFile($pot_filename);
    if ($pot_file->exists) {
        echo "<p>" . _("POT template file") . ": ";
        echo "<a href='{$translate_url}?func=view&amp;locale=template'>" . _("View") . "</a> | <a href='{$translate_url}?func=download&amp;locale=template'>" . _("Download") . "</a> ";
        echo " (" . _("Last modified") . ": " . date("F d Y H:i:s", $pot_file->last_modified) . ")";
        $total_strings = $pot_file->messages_count;
        $translated_strings = $pot_file->messages_translated_count;
        echo "  - " . sprintf(_("%d strings total"), $total_strings);
        echo "</p>";
    } else {
        echo "<p>" . _("No POT template file has been generated.") . "</p>";
    }
    if (in_array("xgettext", $allowed_functions)) {
        echo "<form action='{$translate_url}?func=xgettext' method='POST'>";
        echo "<input type='submit' value='" . attr_safe(_("Regenerate template file")) . "'> ";
        echo _("Run <code>xgettext</code> to generate a fresh template file.");
        echo "</form>\n";
    }
}