<commit_before><?php
/**
 * List avaliable interface translations and actions
 * depending on user right
 * 
 * @package    phpMyFAQ
 * @subpackage Administration
 * @author     <NAME> <<EMAIL>>
 * @since      2009-05-11
 * @copyright  2003-2009 phpMyFAQ Team
 * @version    SVN: $Id$
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */
if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

clearstatcache();

$langDir            = PMF_ROOT_DIR . DIRECTORY_SEPARATOR . "lang";
$transDir           = new DirectoryIterator($langDir);
$isTransDirWritable = is_writable($langDir);
$tt                 = new PMF_TransTool;

printf('<h2>%s</h2>', $PMF_LANG['ad_menu_translations']);
?>
<?php echo $PMF_LANG['msgChooseLanguageToTranslate'] ?>: <br />
<table cellspacing="7">
<?php if(!$isTransDirWritable):
    echo '<tr><td colspan="5"><font color="red">'. $PMF_LANG['msgLangDirIsntWritable'] . "</font></tr></td>";
endif; ?>
<?php if($permission["addtranslation"]): ?>
<tr><td colspan="6">
<a href="?action=transadd"><?php echo $PMF_LANG['msgTransToolAddNewTranslation'] ?></a>
</td></tr>
<?php endif; ?>
<tr><td><?php echo $PMF_LANG['msgTransToolLanguage'] ?></td>
    <td colspan="3"><?php echo $PMF_LANG['msgTransToolActions'] ?></td>
    <td><?php echo $PMF_LANG['msgTransToolWritable'] ?></td>
    <td><?php echo $PMF_LANG['msgTransToolPercent'] ?></td>
</tr>
<?php
    $sortedLangList = array();
    
    foreach ($transDir as $file) {
        if ($file->isFile() && '.php' == PMF_String::substr($file, -4) && 'bak' != PMF_String::substr($file, -7, -4)) {
            $lang = str_replace(array('language_', '.php'), '', $file);

            /**
             * English is our exemplary language which won't be changed
             */
            if('en' == $lang) {
                continue;
            }
            
            $sortedLangList[] = $lang; <commit_msg>prevent showing "add new translation" link if lang dir isn't writeable<commit_after><?php
/**
 * List avaliable interface translations and actions
 * depending on user right
 * 
 * @package    phpMyFAQ
 * @subpackage Administration
 * @author     <NAME> <<EMAIL>>
 * @since      2009-05-11
 * @copyright  2003-2009 phpMyFAQ Team
 * @version    SVN: $Id$
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */
if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

clearstatcache();

$langDir            = PMF_ROOT_DIR . DIRECTORY_SEPARATOR . "lang";
$transDir           = new DirectoryIterator($langDir);
$isTransDirWritable = is_writable($langDir);
$tt                 = new PMF_TransTool;

printf('<h2>%s</h2>', $PMF_LANG['ad_menu_translations']);
?>
<?php echo $PMF_LANG['msgChooseLanguageToTranslate'] ?>: <br />
<table cellspacing="7">
<?php if(!$isTransDirWritable):
    echo '<tr><td colspan="5"><font color="red">'. $PMF_LANG['msgLangDirIsntWritable'] . "</font></tr></td>";
endif; ?>
<?php if($permission["addtranslation"] && $isTransDirWritable): ?>
<tr><td colspan="6">
<a href="?action=transadd"><?php echo $PMF_LANG['msgTransToolAddNewTranslation'] ?></a>
</td></tr>
<?php endif; ?>
<tr><td><?php echo $PMF_LANG['msgTransToolLanguage'] ?></td>
    <td colspan="3"><?php echo $PMF_LANG['msgTransToolActions'] ?></td>
    <td><?php echo $PMF_LANG['msgTransToolWritable'] ?></td>
    <td><?php echo $PMF_LANG['msgTransToolPercent'] ?></td>
</tr>
<?php
    $sortedLangList = array();
    
    foreach ($transDir as $file) {
        if ($file->isFile() && '.php' == PMF_String::substr($file, -4) && 'bak' != PMF_String::substr($file, -7, -4)) {
            $lang = str_replace(array('language_', '.php'), '', $file);

            /**
             * English is our exemplary language which won't be changed
             */
            if('en' == $lang) {
                continue;
            }
            
            $sortedLangList[] = $lang; 
{'fraction_non_alphanumeric': 0.16926229508196722, 'fraction_numerical': 0.011065573770491803, 'mean_word_length': 3.5236329935125115, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686807', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1528, 'n_words': 409}