Added initial version of app/languages

for analyzing missing or overlapping with global text
This commit is contained in:
Matthew Vale 2015-12-10 10:04:35 +00:00
parent e2cc65874d
commit fc9a45d313
10 changed files with 450 additions and 2 deletions

View File

@ -0,0 +1,19 @@
<?php
//application details
$apps[$x]['name'] = "Languages";
$apps[$x]['uuid'] = "23ecb350-b423-428d-9a8d-d617d27b30fe";
$apps[$x]['category'] = "System";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "A tool to analyze languages used in the GUI following https://msdn.microsoft.com/en-gb/library/ee825488%28v=cs.20%29.aspx";
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = "languages_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "29295c90-b1b9-440b-9c7E-c8363c6e8975";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
?>

View File

@ -0,0 +1,24 @@
<?php
$text['title-languages']['en-us'] = "Languages";
$text['title-compare_languages']['en-us'] = "Compare Languages";
$text['header-compare_languages']['en-us'] = "Select Languages";
$text['header-language_results']['en-us'] = "Language results";
$text['warning-incorrect_language_culture_code']['en-us'] = "the language culture code does not follow the normal format see - ";
$text['warning-global_already_defined']['en-us'] = "Global already defines this text as ";
$text['label-culture_code']['en-us'] = "Culture Code";
$text['label-flag']['en-us'] = "Flag";
$text['label-reference_language']['en-us'] = "Reference Language";
$text['label-target_language']['en-us'] = "Target Language";
$text['label-tag']['en-us'] = "Tag";
$text['label-app_target']['en-us'] = "Application";
$text['description-languages']['en-us'] = "Languages listed below are managed in /resources/app_languages.php";
$text['description-compare_languages']['en-us'] = "Compare laguages between different cultures";
$text['description-reference_language']['en-us'] = "Language to use for reference of missing text";
$text['description-target_language']['en-us'] = "Language to compare";
?>

View File

@ -0,0 +1,21 @@
<?php
$apps[$x]['menu'][0]['title']['en-us'] = "Languages";
$apps[$x]['menu'][0]['title']['es-cl'] = "";
$apps[$x]['menu'][0]['title']['fr-fr'] = "";
$apps[$x]['menu'][0]['title']['pt-pt'] = "";
$apps[$x]['menu'][0]['title']['pt-br'] = "";
$apps[$x]['menu'][0]['title']['pl'] = "";
$apps[$x]['menu'][0]['title']['sv-se'] = "";
$apps[$x]['menu'][0]['title']['uk'] = "";
$apps[$x]['menu'][0]['title']['ro'] = "";
$apps[$x]['menu'][0]['title']['de-at'] = "";
$apps[$x]['menu'][0]['title']['ar-eg'] = "";
$apps[$x]['menu'][0]['title']['he'] = "";
$apps[$x]['menu'][0]['uuid'] = "13a8fd28-6718-4ac1-8acc-0bcffbce29c3";
$apps[$x]['menu'][0]['parent_uuid'] = "0438b504-8613-7887-c420-c837ffb20cb1";
$apps[$x]['menu'][0]['category'] = "internal";
$apps[$x]['menu'][0]['path'] = "/app/languages/index.php";
$apps[$x]['menu'][0]['groups'][] = "superadmin";
?>

100
app/languages/index.php Normal file
View File

@ -0,0 +1,100 @@
<?php
/*
FusionPBX
Version: MPL 1.1
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.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Matthew Vale <github@mafoo.org>
*/
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('languages_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//additional includes
require_once "resources/header.php";
require_once "resources/paging.php";
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-languages']."</b></td>\n";
echo " <td width='50%' align='right'>&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-languages']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
//table headers
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th nowrap='' style='width:2em'>".$text['label-flag']."</th>\n";
echo th_order_by('language_code', $text['label-culture_code'], $order_by, $order, '', "style='width:4em;'");
echo th_order_by('language_name', $text['label-name'], $order_by, $order);
echo "</tr>\n";
$c= 0;
$warn_about_wrong_culture = false;
foreach($_SESSION['app']['languages'] as $lang_code){ //TODO add sorting
$tr_link = "href='languages_compare.php?target_language=$lang_code'";
echo "<tr $tr_link>\n";
echo "<td class='row_style".($c%2)."'>";
echo "<img src='$project_path/themes/flags/$lang_code.png' alt='$lang_code'/></td>";
echo "<td class='row_style".($c%2)."'>$lang_code";
if(strlen($lang_code) < 5){
$warn_about_wrong_culture = true;
echo "$nbsp;<sup>*1</sup>";
}
echo "</td>";
echo "<td class='row_style".($c%2)."'>".$text["language-$lang_code"]."</td>";
echo "</tr>\n";
$c++;
}
//complete the content
echo "</table>";
if($warn_about_wrong_culture){
$lang_code = $_SESSION['domain']['language']['code'];
echo "<p><sup>*1</sup>&nbsp;".$text['warning-incorrect_language_culture_code']."<a href='https://msdn.microsoft.com/$lang_code/library/ee825488%28v=cs.20%29.aspx'>https://msdn.microsoft.com/$lang_code/library/ee825488%28v=cs.20%29.aspx</a></p>";
}
//include the footer
require_once "resources/footer.php";
?>

View File

@ -0,0 +1,230 @@
<?php
/*
FusionPBX
Version: MPL 1.1
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.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Matthew Vale <github@mafoo.org>
*/
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('languages_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get http post variables and set them to php variables
$reference_language = $_SESSION['domain']['language']['code'];
$target_language = check_str($_GET["target_language"]);
$app_target = 'resources';
if (count($_POST) > 0) {
//set the variables
$reference_language = check_str($_POST["reference_language"]);
$target_language = check_str($_POST["target_language"]);
$app_target = check_str($_POST["app_target"]);
}
//collect languages
$language = new text;
$language_text = $language->get('all', $app_target, true);
foreach ($language_text as $lang_label => $lang_codes) {
$language_labels[] = $lang_label;
$reference_text[$lang_label] = $lang_codes[$reference_language];
$target_text[$lang_label] = $lang_codes[$target_language];
}
sort($language_labels);
if($app_target != 'resources'){
$global_text = $language->get($reference_language, 'resources', true);
}
unset($language_text);
//add multi-lingual support
$text = $language->get();
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$app_list;
$x=0;
foreach ($config_list as $config_path) {
include($config_path);
$dirs = explode("/", $config_path);
$app_path = $dirs[(sizeof($dirs)-3)] . "/" . $dirs[(sizeof($dirs)-2)];
$app_name = $apps[$x]['name'];
if( strlen($app_name) == 0) { $app_name = $app_path; }
$app_list[$app_name] = $app_path;
$x++;
}
$theme_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/themes/*/app_languages.php");
foreach ($theme_list as $config_path) {
$dirs = explode("/", $config_path);
$app_path = $dirs[(sizeof($dirs)-3)] . "/" . $dirs[(sizeof($dirs)-2)];
$app_name = 'Theme - ' . $dirs[(sizeof($dirs)-2)];
$app_list[$app_name] = $app_path;
}
unset($apps);
ksort($app_list);
//additional includes
require_once "resources/header.php";
require_once "resources/paging.php";
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//show the content
echo "<p>\n";
echo "<b>".$text['title-compare_languages']."</b><br/>\n";
echo $text['description-compare_languages']."\n";
echo "</p>\n";
//select comparison
echo "<span><b>".$text['header-compare_languages']."</b><br/></span>\n";
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-reference_language']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<fieldset class='container'>";
foreach($_SESSION['app']['languages'] as $lang_code){
echo "<fieldset class='container'>";
echo " <label class='radio' style='width:200px;'>";
echo "<input type='radio' name='reference_language' value='$lang_code' id='reference_language_$lang_code'";
if($lang_code == $reference_language)
{
echo " checked='checked'";
}
echo "/>";
echo "<img src='$project_path/themes/flags/$lang_code.png' alt='$lang_code'/>&nbsp;".$text["language-$lang_code"];
echo "</label>\n";
echo "</fieldset>";
}
echo "</fieldset>";
echo "<br />".$text['description-reference_language']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-target_language']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<fieldset class='container'>";
foreach($_SESSION['app']['languages'] as $lang_code){
echo "<fieldset class='container'>";
echo " <label class='radio' style='width:200px;'>";
echo "<input type='radio' name='target_language' value='$lang_code' id='target_language_$lang_code'";
if($lang_code == $target_language)
{
echo " checked='checked'";
}
echo "/>";
echo "<img src='$project_path/themes/flags/$lang_code.png' alt='$lang_code'/>&nbsp;".$text["language-$lang_code"];
echo "</label>\n";
echo "</fieldset>";
}
echo "</fieldset>";
echo "<br />".$text['description-app_target']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-application']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='app_target' id='app_target' class='formfld'>\n";
echo " <option value='resources'";
if($app_target == 'resources') { echo " selected='selected'"; }
echo ">Global</option>\n";
echo " <option value=''>==========</option>";
foreach($app_list as $app => $app_path ) {
echo " <option value='$app_path'";
if($app_target == $app_path) { echo " selected='selected'"; }
echo ">".$app."</option>\n";
}
echo " </select>\n";
echo " <br />".$text['description-app_target']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo " <div style='text-align:right'>\n";
echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
echo " <button type='submit' id='next'>".$text['button-search']."</button>\n";
echo " </div>\n";
echo "</form>\n";
echo "<br/>\n";
//render the texts
echo "<span><b>".$text['header-language_results']."</b> for '$app_target/app_languages.php'<br/></span>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>".$text['label-tag']."</th>";
echo "<th><img src='$project_path/themes/flags/$reference_language.png' alt='$reference_language'/>&nbsp;".$text["language-$reference_language"]."</th>\n";
if(strlen($target_language) > 0 ) { echo "<th><img src='$project_path/themes/flags/$target_language.png' alt='$target_language'/>&nbsp;".$text["language-$target_language"]."</th>\n"; }
echo "</tr>\n";
$language_count = 0;
foreach ($language_labels as $lang_label){
if( preg_match( '/\Alanguage-\w{2}(?:-\w{2})?\z/', $lang_label) ) { break; }
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>$lang_label";
if(isset($global_text[$lang_label])){
echo "&nbsp;<img src='$project_path/themes/enhanced/images/warning.png' alt='!' title=\"".$text['warning-global_already_defined']."'".$global_text[$lang_label]."'\"/>";
}
echo "</td>\n";
echo "<td class='vtable' align='left'>";
if(strlen($reference_text[$lang_label]) == 0) {
echo "<b>Missing!</b>";
}else{
echo $reference_text[$lang_label];
}
echo "</td>\n";
if(strlen($target_language) > 0 ) {
echo "<td class='vtable' align='left'>";
if(strlen($target_text[$lang_label]) == 0) {
echo "<b>Missing!</b>";
}else{
echo $target_text[$lang_label];
}
echo "</td>\n";
}
echo "</tr>\n";
$language_count++;
}
if($language_count == 0){
echo "<tr><td colspan='3'>Sorry, this app hasn't defined any text</td></tr>\n";
}
echo "</table>\n";
//include the footer
require_once "resources/footer.php";
?>

52
app/languages/root.php Normal file
View File

@ -0,0 +1,52 @@
<?php
/*
FusionPBX
Version: MPL 1.1
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.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Callblock is written by Gerrit Visser <gerrit308@gmail.com>
*/
// make sure the PATH_SEPARATOR is defined
if (!defined("PATH_SEPARATOR")) {
if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
}
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
// if the project directory exists then add it to the include path otherwise add the document root to the include path
if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
}
else {
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
}
?>

View File

@ -25,9 +25,11 @@ class text {
* @var string $language_code examples: en-us, es-cl, fr-fr, pt-pt
* @var string $app_path examples: app/exec or core/domains
*/
public function get($language_code = null, $app_path = null) {
public function get($language_code = null, $app_path = null, $exclude_global = false) {
//get the global app_languages.php
if(!$exclude_global){
include $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/app_languages.php";
}
//get the app_languages.php
if ($app_path != null) {
$lang_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/".$app_path."/app_languages.php";

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B