Skip to content

Commit

Permalink
moneymanagerex#25 Translation with php array files
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaritossa committed Oct 22, 2023
1 parent 3c97340 commit 3448186
Show file tree
Hide file tree
Showing 17 changed files with 356 additions and 81 deletions.
2 changes: 1 addition & 1 deletion WebApp/_btn_back.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="div_btn_back">
<a href="landing.php" class="btn btn-lg btn-primary btn-block">Ritorna al menu</a>
<a href="landing.php" class="btn btn-lg btn-primary btn-block"><?php echo $lang["return_to_menu"] ?></a>
</div>
2 changes: 1 addition & 1 deletion WebApp/_btn_logout.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="div_btn_logout">
<a href="logout.php" class="btn btn-lg btn-success btn-block">Esci</a>
<a href="logout.php" class="btn btn-lg btn-success btn-block"><?php echo $lang["sec.logout"] ?></a>
</div>
2 changes: 1 addition & 1 deletion WebApp/_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
if (!isset($b_debug))
{
$b_debug = false;
}
}
5 changes: 5 additions & 0 deletions WebApp/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
require_once 'configuration_user.php';
}

require_once 'languages/en.php';

if (isset($language) && $language != 'en' && file_exists('languages/'.$language.'.php'))
include_once 'languages/'.$language.'.php';

require_once 'functions_design.php';
require_once 'functions_database.php';
require_once 'functions_security.php';
Expand Down
6 changes: 6 additions & 0 deletions WebApp/functions_costant.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,10 @@ public static function current_page_url ()
{$pageURL .= ':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];}
return $pageURL;
}

public static function language ()
{
global $language;
return $language;
}
}
95 changes: 75 additions & 20 deletions WebApp/functions_design.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class design
//Create date input element
public static function input_date ($TrDateDefault)
{
global $lang;

echo "<div class='form-group'>";
echo "<label for='Date'>Data</label>";
echo "<label for='Date'>{$lang["trans.date"]}</label>";
echo "<input id = 'Date' type='date' name='Date' class='form-control' value = '${TrDateDefault}'/>";
echo "<span class='help-block'></span>";
echo "</div>\n";
Expand All @@ -20,11 +22,20 @@ public static function input_date ($TrDateDefault)
//Create status input element
public static function input_status ($TrStatusDefault)
{
$StatusArrayDesc = array ("Non Riconciliata", "Riconciliata", "Nulla", "Da Monitorare", "Duplicata");
global $lang;

$StatusArrayDesc = array (
$lang["trans.status.none"],
$lang["trans.status.reconciled"],
$lang["trans.status.void"],
$lang["trans.status.follow-up"],
$lang["trans.status.duplicate"]
);

$StatusArrayDB = array ("", "R", "V", "F", "D");

echo "<div class='form-group'>";
echo "<label for='Status'>Stato</label>";
echo "<label for='Status'>{$lang["trans.status"]}</label>";
echo "<select id ='Status' name='Status' class='form-control'>";
for ($i = 0; $i < sizeof($StatusArrayDesc); $i++)
{
Expand All @@ -42,11 +53,17 @@ public static function input_status ($TrStatusDefault)
//Create type input element
public static function input_type ($TrTypeDefault)
{
$TypeArrayDesc = array ('Prelievo', 'Deposito', 'Trasferimento');
global $lang;

$TypeArrayDesc = array (
$lang["trans.type.withdrawal"],
$lang["trans.type.deposit"],
$lang["trans.type.transfer"]
);
$TypeArrayCode = array ('Withdrawal', 'Deposit', 'Transfer');

echo '<div class="form-group">';
echo '<label for="Type">Tipo</label>';
echo "<label for='Type'>{$lang["trans.type"]}</label>";
# echo '<select id="Type" name="Type" class="form-control" onchange="enable_element(\'ToAccount\',\'Type\',\'Transfer\'); disable_element(\'Payee\',\'Type\',\'Transfer\')">';
$on_change = 'onchange="enable_element(\'ToAccount\',\'Type\',\'Transfer\'); disable_element(\'Payee\',\'Type\',\'Transfer\')"';
for ($i = 0; $i < sizeof($TypeArrayCode); $i++)
Expand All @@ -73,12 +90,14 @@ public static function input_type ($TrTypeDefault)
//Create account input element
public static function input_account ($TrAccountDefault)
{
global $lang;

$AccountArrayDesc = db_function::bankaccount_select_all();
if (sizeof($AccountArrayDesc) == 0)
{$AccountArrayDesc[0] = "None";}

echo "<div class='form-group'>";
echo "<label for='Account'>Conto</label>";
echo "<label for='Account'>{$lang["trans.account"]}</label>";
echo "<select id ='Account' name='Account' class='form-control'>";
for ($i = 0; $i < sizeof($AccountArrayDesc); $i++)
{
Expand All @@ -96,11 +115,13 @@ public static function input_account ($TrAccountDefault)
//Create toaccount input element
public static function input_toaccount ($TrToAccountDefault)
{
global $lang;

$ToAccountArrayDesc = db_function::bankaccount_select_all();
array_unshift($ToAccountArrayDesc,"None");

echo "<div class='form-group'>";
echo "<label for='ToAccount'>Al Conto</label>";
echo "<label for='ToAccount'>{$lang["trans.to-account"]}</label>";
echo "<select id ='ToAccount' name='ToAccount' class='form-control'>";
for ($i = 0; $i < sizeof($ToAccountArrayDesc); $i++)
{
Expand All @@ -118,12 +139,14 @@ public static function input_toaccount ($TrToAccountDefault)
//Create payee input element
public static function input_payee ($TrPayeeDefault)
{
global $lang;

$PayeeArrayDesc = db_function::payee_select_all_name();
array_unshift($PayeeArrayDesc,"None");

echo "<div class='form-group'>";
echo "<label for='Payee'>Beneficiario</label>";
echo "<input id='Payee' type='text' name='Payee' class='form-control' placeholder='Scegli un beneficiario' autocomplete = 'off' required />";
echo "<label for='Payee'>{$lang["trans.payee"]}</label>";
echo "<input id='Payee' type='text' name='Payee' class='form-control' placeholder='{$lang["trans.payee.placeholder"]}' autocomplete = 'off' required />";
echo "<span class='help-block'></span>";
echo "</div>\n";

Expand All @@ -139,12 +162,14 @@ public static function input_payee ($TrPayeeDefault)
//Create category input element
public static function input_category ($TrCategoryDefault)
{
global $lang;

$CategoryArrayDesc = db_function::category_select_distinct();
array_unshift($CategoryArrayDesc,"None");

echo "<div class='form-group'>";
echo "<label for='Category'>Categoria</label>";
echo "<input id='Category' type='text' name='Category' class='form-control' placeholder='Scegli una categoria' autocomplete = 'off' required />";
echo "<label for='Category'>{$lang["trans.category"]}</label>";
echo "<input id='Category' type='text' name='Category' class='form-control' placeholder='{$lang["trans.category.placeholder"]}' autocomplete = 'off' required />";
echo "<span class='help-block'></span>";
echo "</div>\n";

Expand All @@ -160,9 +185,11 @@ public static function input_category ($TrCategoryDefault)
//Create subcategory input element
public static function input_subcategory ($TrSubCategoryDefault)
{
global $lang;

echo "<div class='form-group'>";
echo "<label for='SubCategory'>Sotto-Categoria</label>";
echo "<input id='SubCategory' type='text' name='SubCategory' class='form-control' placeholder='Scegli una sotto-categoria' autocomplete='off' />";
echo "<label for='SubCategory'>{$lang["trans.sub-category"]}</label>";
echo "<input id='SubCategory' type='text' name='SubCategory' class='form-control' placeholder='{$lang["trans.sub-category.placeholder"]}' autocomplete='off' />";
echo "<span class='help-block'></span>";
echo "</div>\n";

Expand All @@ -176,15 +203,17 @@ public static function input_subcategory ($TrSubCategoryDefault)
//Create amount input element
public static function input_amount ($TrAmountDefault)
{
global $lang;

echo "<div class='form-group'>";
echo "<label for='Amount'>Importo</label>";
echo "<label for='Amount'>{$lang["trans.amount"]}</label>";
if ($TrAmountDefault <> 0)
{
echo "<input id='Amount' type='number' name='Amount' class='form-control' placeholder='Importo operazione' min='0.01' step ='0.01' value='${TrAmountDefault}' required />";
echo "<input id='Amount' type='number' name='Amount' class='form-control' placeholder='{$lang["trans.amount.placeholder"]}' min='0.01' step ='0.01' value='${TrAmountDefault}' required />";
}
else
{
echo "<input id='Amount' type='number' name='Amount' class='form-control' placeholder='Importo operazione' min='0.01' step ='0.01' required />";
echo "<input id='Amount' type='number' name='Amount' class='form-control' placeholder='{$lang["trans.amount.placeholder"]}' min='0.01' step ='0.01' required />";
}
echo "<span class='help-block'></span>";
echo "</div>\n";
Expand All @@ -195,15 +224,17 @@ public static function input_amount ($TrAmountDefault)
//Create notes input element
public static function input_notes ($TrNotesDefault)
{
global $lang;

echo "<div class='form-group'>";
echo "<label for='Notes'>Note</label>";
echo "<label for='Notes'>{$lang["trans.notes"]}</label>";
if ($TrNotesDefault <> "Empty")
{
echo "<textarea id='Notes' name='Notes' class='form-control' rows='5' placeholder='Eventuali note'>${TrNotesDefault}</textarea>";
echo "<textarea id='Notes' name='Notes' class='form-control' rows='5' placeholder='{$lang["trans.notes.placeholder"]}'>${TrNotesDefault}</textarea>";
}
else
{
echo "<textarea id='Notes' name='Notes' class='form-control' rows='5' placeholder='Eventuali note'></textarea>";
echo "<textarea id='Notes' name='Notes' class='form-control' rows='5' placeholder='{$lang["trans.notes.placeholder"]}'></textarea>";
}
echo "<span class='help-block'></span>";
echo "</div>\n";
Expand Down Expand Up @@ -282,12 +313,14 @@ public static function settings_password ($VarName,$PlaceHolder,$Required,$Label
//Design setting default account
public static function settings_default_account ($TrAccountDefault)
{
global $lang;

$AccountArrayDesc = db_function::bankaccount_select_all();
if (sizeof($AccountArrayDesc) == 0)
{$AccountArrayDesc[0] = "None";}

echo "<div class='form-group'>";
echo "<label for='Default_Account'>Conto di Default</label>";
echo "<label for='Default_Account'>{$lang["settings.default-account"]}</label>";
echo "<select id ='Default_Account' name='Default_Account' class='form-control'>";
for ($i = 0; $i < sizeof($AccountArrayDesc); $i++)
{
Expand Down Expand Up @@ -317,4 +350,26 @@ public static function table_cell ($value,$css_class,$s_extra='')
echo $value;
echo '</td>';
}

//Create account input element
public static function settings_language ($Language)
{
global $lang;

$AvailableLanguages = array("en","it");

echo "<div class='form-group'>";
echo "<label for='Language'>{$lang["settings.language"]}</label>";
echo "<select id ='Language' name='Language' class='form-control'>";
for ($i = 0; $i < sizeof($AvailableLanguages); $i++)
{
if ($AvailableLanguages[$i] == $Language)
{echo "<option value=\"{$AvailableLanguages[$i]}\" selected> {$AvailableLanguages[$i]} </option>";}
else
{echo "<option value=\"{$AvailableLanguages[$i]}\"> {$AvailableLanguages[$i]} </option>";}
}
echo "</select>";
echo "<span class='help-block'></span>";
echo "</div>\n";
}
}
11 changes: 6 additions & 5 deletions WebApp/functions_various.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ public static function getPageUrl() : String
*/
public static function getPagesList() : Array
{
global $lang;
$pages_list = [
'new_transaction' => 'Nuova operazione',
'show' => 'Lista operazioni',
'settings' => 'Impostazioni',
'guide' => 'Guida',
'about' => 'About',
'new_transaction' => $lang["page.new-transaction"],
'show' => $lang["page.show-transactions"],
'settings' => $lang["page.settings"],
'guide' => $lang["page.guide"],
'about' => $lang["page.about"]
];
return $pages_list;
}
Expand Down
10 changes: 5 additions & 5 deletions WebApp/guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
<p>
<ol>
<li>
Copia le informazioni qui sotto e incollale nell'applicazione desktop.
<?php echo $lang["guide.step1"] ?>
</li>
<li>
Riapri l'applicazione desktop per sincronizzare i conti, i beneficiari, etc. sulla WebApp.
<?php echo $lang["guide.step2"] ?>
</li>
<li>
Inizia ad usare la WebApp.
<?php echo $lang["guide.step3"] ?>
</li>
</ol>
</p>
</div>
<div class="container text_align_center">
<h4>
WebApp URL:
<?php echo $lang["guide.webapp-url"] ?>
</h4>
<p>
<strong>
Expand All @@ -35,7 +35,7 @@
</p>
<br />
<h4>
Desktop GUID:
<?php echo $lang["guide.desktop-guid"] ?>
</h4>
<p>
<strong>
Expand Down
12 changes: 6 additions & 6 deletions WebApp/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$upgrade_result = db_upgrade::upgrade_db();
if ($upgrade_result == 'update_done')
{
various::send_alert_and_redirect('Database aggiornato con successo alla versione '.costant::app_version(), 'index.php');
various::send_alert_and_redirect($lang["db_successfully_updated_to_version"].costant::app_version(), 'index.php');
}
}
$username = null;
Expand Down Expand Up @@ -71,17 +71,17 @@
<div class="container text_align_center">
<form id="login" method="post">
<div class="form-group">
<label for="Username">Username</label>
<input id="Username" type="text" name="Username" class="form-control" placeholder="Inserisci lo Username" autofocus required />
<label for="Username"><?php echo $lang["sec.username"]; ?></label>
<input id="Username" type="text" name="Username" class="form-control" placeholder="<?php echo $lang["sec.username.placeholder"] ?>"" autofocus required />
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="Password">Password</label>
<input id="Password" type="password" name="Password" class="form-control" placeholder="Inserisci la Password" required />
<label for="Password"><?php echo $lang["sec.password"]; ?></label>
<input id="Password" type="password" name="Password" class="form-control" placeholder="<?php echo $lang["sec.password.placeholder"] ?>" required />
<span class="help-block"></span>
</div>
<br />
<button type="submit" id="Login" name="Login" class="btn btn-lg btn-success btn-block" value = "Login">Accedi</button>
<button type="submit" id="Login" name="Login" class="btn btn-lg btn-success btn-block" value = "Login"><?php echo $lang["sec.login"] ?></button>
</form>
</div>
<?php
Expand Down
12 changes: 6 additions & 6 deletions WebApp/insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
switch ($TrEditedNr)
{
case -1:
$s_page_title = 'Nuova Operazione';
$s_page_title = $lang["page.transaction.added"];
$transaction_action = 'added';
break;
case 0:
$s_page_title = 'Operazione Esistente';
$s_page_title = $lang["page.transaction.duplicated"];
$transaction_action = 'duplicated';
break;
default:
$s_page_title = 'Operazione Esistente';
$s_page_title = $lang["page.transaction.updated"];
$transaction_action = 'updated';
break;
}
Expand Down Expand Up @@ -84,13 +84,13 @@
check_box
</i>
<h3>
<?php echo ucfirst($transaction_action); ?> con successo
<?php echo $lang["trans.msg.action-".$transaction_action.".successfully"] ?>
</h3>
<br />
<br />
<a href="new_transaction.php" class="btn btn-lg btn-success btn-block">Aggiungi altra operazione</a>
<a href="new_transaction.php" class="btn btn-lg btn-success btn-block"><?php echo $lang["trans.msg.add-next"] ?></a>
<br />
<a href="show.php" class="btn btn-lg btn-success btn-block">Lista operazioni</a>
<a href="show.php" class="btn btn-lg btn-success btn-block"><?php echo $lang["page.show-transactions"] ?></a>
<br />
</div>

Expand Down
Loading

0 comments on commit 3448186

Please sign in to comment.