diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-25 22:59:56 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-25 22:59:56 +0545 |
commit | cadeb9fd98e860c84658c84cdc0b3c050b7ee326 (patch) | |
tree | d80fddb0b926ea3d420015eb3fbc905f59b33028 /src/usr/local/www | |
parent | 2127e42cc94b8bf0c16f40b8efef2f65acde6204 (diff) | |
download | pfsense-cadeb9fd98e860c84658c84cdc0b3c050b7ee326.zip pfsense-cadeb9fd98e860c84658c84cdc0b3c050b7ee326.tar.gz |
Internationalization of pkg*.php
Various sentences were being built up from gettext() of individual words
or phrases concatenated together. That will not work for translation to
languages with different word order, so I have restructured that.
Note: TODO: The countdown timer text with seconds countdown is all in JS
so I will think about how that can be translated nicely.
Diffstat (limited to 'src/usr/local/www')
-rwxr-xr-x | src/usr/local/www/pkg.php | 24 | ||||
-rw-r--r-- | src/usr/local/www/pkg_edit.php | 5 | ||||
-rw-r--r-- | src/usr/local/www/pkg_mgr.php | 2 | ||||
-rw-r--r-- | src/usr/local/www/pkg_mgr_install.php | 50 |
4 files changed, 46 insertions, 35 deletions
diff --git a/src/usr/local/www/pkg.php b/src/usr/local/www/pkg.php index ac085b4..6492ac0 100755 --- a/src/usr/local/www/pkg.php +++ b/src/usr/local/www/pkg.php @@ -95,7 +95,7 @@ if ($xml == "") { $pkg = parse_xml_config_pkg($pkg_full_path, "packagegui"); } else { include("head.inc"); - print_info_box(gettext("File not found ") . htmlspecialchars($xml)); + print_info_box(sprintf(gettext("File not found %s"), htmlspecialchars($xml))); include("foot.inc"); exit; } @@ -350,7 +350,7 @@ if ($savemsg) { } } echo "<tr><td colspan='$colspan' class='text-center'>"; - echo "Filter by: "; + echo gettext("Filter by: "); $isfirst = true; for ($char = 65; $char < 91; $char++) { if (!$isfirst) { @@ -362,7 +362,7 @@ if ($savemsg) { echo "</td></tr>"; echo "<tr><td colspan='$colspan' class='text-center'>"; if ($field['sortablefields']) { - echo "Filter field: <select name='pkg_filter_type'>"; + echo gettext("Filter field: ") . "<select name='pkg_filter_type'>"; foreach ($field['sortablefields']['item'] as $si) { if ($si['name'] == $_REQUEST['pkg_filter_type']) { $SELECTED = "selected"; @@ -374,7 +374,7 @@ if ($savemsg) { echo "</select>"; } if ($include_filtering_inputbox) { - echo " Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /><input type='submit' value='Filter' />"; + echo " " . gettext("Filter text: ") . "<input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /><input type='submit' value='Filter' />"; } echo "</td></tr><tr><td><font size='-3'> </font></td></tr>"; } @@ -405,8 +405,8 @@ if ($savemsg) { echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>"; echo "<table width='100%' summary=''>"; echo "<tr>"; - echo "<td class='text-left'>Displaying page $page of $totalpages</b></td>"; - echo "<td class='text-right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>"; + echo "<td class='text-left'>" . sprintf(gettext('Displaying page %1$s of %2$s'), $page, $totalpages) . "</b></td>"; + echo "<td class='text-right'>" . gettext("Rows per page: ") . "<select onchange='document.pkgform.submit();' name='display_maximum_rows'>"; for ($x = 0; $x < 250; $x++) { if ($x == $display_maximum_rows) { $SELECTED = "selected"; @@ -534,14 +534,14 @@ if ($savemsg) { <tr> <?php #Show custom description to edit button if defined - $edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item"); + $edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:gettext("Edit this item")); ?> <td><a class="fa fa-pencil" href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>" title="<?=$edit_msg?>"></a></td> <?php #Show custom description to delete button if defined - $delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item"); + $delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:gettext("Delete this item")); ?> - <td> <a class="fa fa-trash" href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i?>" title="<?=gettext("Delete")?>"></a></td> + <td> <a class="fa fa-trash" href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i?>" title="<?=$delete_msg?>"><?=gettext('Delete')?></a></td> </tr> </tbody> </table> @@ -563,7 +563,7 @@ if ($savemsg) { } else if ($startdisplayingat > 1) { $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0&display_maximum_rows={$display_maximum_rows}'>"; } - $final_footer .= "<font size='2'><< Previous page</font></a>"; + $final_footer .= "<font size='2'><< " . gettext("Previous page") . "</font></a>"; if ($tmppp + $display_maximum_rows > count($evaledvar)) { $endingrecord = count($evaledvar); } else { @@ -576,7 +576,7 @@ if ($savemsg) { if (($i+1) < count($evaledvar)) { $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&display_maximum_rows={$display_maximum_rows}'>"; } - $final_footer .= "<font size='2'>Next page >></font></a>"; + $final_footer .= "<font size='2'>" . gettext("Next page") . " >></font></a>"; $final_footer .= "</td></tr></table></td></tr>"; $i = count($evaledvar); break; @@ -594,7 +594,7 @@ if ($savemsg) { <tr> <?php #Show custom description to add button if defined - $add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item"); + $add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:gettext("Add a new item")); ?> <td><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>" class="btn btn-sm btn-success" title="<?=$add_msg?>"><?=gettext('Add')?></a></td> <?php diff --git a/src/usr/local/www/pkg_edit.php b/src/usr/local/www/pkg_edit.php index 81551ec..2db6b6e 100644 --- a/src/usr/local/www/pkg_edit.php +++ b/src/usr/local/www/pkg_edit.php @@ -1193,11 +1193,12 @@ foreach ($pkg['fields']['field'] as $pkga) { sort($ips); if (isset($pkga['showlistenall'])) { - array_unshift($ips, array('ip' => 'All', 'description' => 'Listen on All interfaces/ip addresses ')); + array_unshift($ips, array('ip' => gettext('All'), 'description' => gettext('Listen on All interfaces/ip addresses '))); } if (!preg_match("/$interface_regex/", "loopback")) { - $iface_description=(isset($pkga['showips']) ? "127.0.0.1 (loopback)" : "loopback"); + $loopback_text = gettext("loopback"); + $iface_description=(isset($pkga['showips']) ? "127.0.0.1 (" . $loopback_text . ")" : $loopback_text); array_push($ips, array('ip' => 'lo0', 'description' => $iface_description)); } diff --git a/src/usr/local/www/pkg_mgr.php b/src/usr/local/www/pkg_mgr.php index 9d30f8a..ecc4cad 100644 --- a/src/usr/local/www/pkg_mgr.php +++ b/src/usr/local/www/pkg_mgr.php @@ -197,7 +197,7 @@ display_top_tabs($tab_array); <a id="btnclear" title="<?=gettext("Clear")?>" class="btn btn-default btn-sm"><?=gettext("Clear")?></a> </div> <div class="col-sm-10 col-sm-offset-2"> - <span class="help-block">Enter a search string or *nix regular expression to search package names and descriptions.</span> + <span class="help-block"><?=gettext('Enter a search string or *nix regular expression to search package names and descriptions.')?></span> </div> </div> </div> diff --git a/src/usr/local/www/pkg_mgr_install.php b/src/usr/local/www/pkg_mgr_install.php index 6807255..6f86cf4 100644 --- a/src/usr/local/www/pkg_mgr_install.php +++ b/src/usr/local/www/pkg_mgr_install.php @@ -292,13 +292,14 @@ if ($input_errors) { switch ($pkgmode) { case 'reinstallpkg': - $pkgtxt = 'reinstalled'; + $pkgtxt = sprintf(gettext('Package <b>%s</b> will be reinstalled'), $pkgname); break; case 'delete': - $pkgtxt = 'removed'; + $pkgtxt = sprintf(gettext('Package <b>%s</b> will be removed'), $pkgname); break; + case 'installed': default: - $pkgtxt = $pkgmode; + $pkgtxt = sprintf(gettext('Package <b>%s</b> will be installed'), $pkgname); break; } ?> @@ -313,7 +314,7 @@ if ($input_errors) { <?php } else if ($_GET['from'] && $_GET['to']) { ?> - Package: <b><?=$pkgname;?></b> will be upgraded from <b><?=$_GET['from']?></b> to <b><?=$_GET['to']?></b>. + <?=sprintf(gettext('Package: %1$s will be upgraded from %2$s to %3$s.'), '<b>' . $pkgname . '</b>', '<b>' . $_GET['from'] . '</b>', '<b>' . $_GET['to'] . '</b>')?> <?php } else if ($firmwareupdate) { ?> @@ -321,7 +322,7 @@ if ($input_errors) { <?php } else { ?> - Package: <b><?=$pkgname;?></b> will be <?=$pkgtxt;?>. + <?=$pkgtxt;?>. <?php } ?> @@ -389,12 +390,25 @@ if ($firmwareupdate && !$firmwareversion) { print_info_box(gettext("Unable to retrieve system versions"), 'danger'); } +if ($_POST) { + $pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401)); +} + if ($_POST['mode'] == 'delete') { - $modetxt = gettext("removal"); + $panel_heading_txt = gettext("Package removal"); + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> removal successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> removal failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the removal of <b>%1$s</b> completes.'), $pkgid); } else if (($_POST['mode'] == 'reinstallpkg') || ($_POST['mode'] == 'reinstallall')) { - $modetxt = gettext("reinstallation"); + $panel_heading_txt = gettext("Package reinstallation"); + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> reinstallation successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> reinstallation failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the reinstallation of <b>%1$s</b> completes.'), $pkgid); } else { - $modetxt = gettext("installation"); + $panel_heading_txt = gettext("Package installation"); + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> installation successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> installation failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the installation of <b>%1$s</b> completes.'), $pkgid); } if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): @@ -423,7 +437,7 @@ if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): <h2 class="panel-title" id="status"><?=gettext("Updating system")?></h2> <?php } else { ?> - <h2 class="panel-title" id="status"><?=gettext("Package") . " " . $modetxt?></h2> + <h2 class="panel-title" id="status"><?=$panel_heading_txt?></h2> <?php } ?> </div> @@ -441,10 +455,6 @@ if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): ob_flush(); -if ($_POST) { - $pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401)); -} - if ($_POST && ($_POST['completed'] != "true")) { /* Write out configuration to create a backup prior to pkg install. */ write_config(gettext("Creating restore point before package installation.")); @@ -520,9 +530,9 @@ function show_success() { $('#final').removeClass("alert-info").addClass("alert-success"); if ("<?=$_POST['mode']?>" != "reinstallall") { if ("<?=$pkgid?>" == "firmware") { - $('#final').html("<b>" + "System update" + " " + "<?=gettext(' successfully completed')?>"); + $('#final').html("<b>" + "<?=gettext('System update successfully completed')?>" + "</b>"); } else { - $('#final').html("<b>" + "<?=$pkgid?>" + " </b>" + "<?=$modetxt?>" + " " + "<?=gettext(' successfully completed')?>"); + $('#final').html("<?=$pkg_success_txt?>"); } } else { $('#final').html("<?=gettext('Reinstallation of all packages successfully completed')?>"); @@ -536,7 +546,7 @@ function show_failure() { $('#final').removeClass("alert-info"); $('#final').addClass("alert-danger"); if ("<?=$_POST['mode']?>" != "reinstallall") { - $('#final').html("<?=$pkgid?>" + " " + "<?=$modetxt?>" + " " + "<?=gettext(' failed!')?>"); + $('#final').html("<?=$pkg_fail_txt?>"); } else { $('#final').html("<?=gettext('Reinstallation of all packages failed')?>"); } @@ -547,10 +557,10 @@ function show_failure() { function show_info() { $('#final').addClass("alert-info"); if ("<?=$_POST['mode']?>" != "reinstallall") { - $('#final').html("Please wait while the " + "<?=$modetxt?>" + " of " + "<?=$pkgid?>" + " " + "completes." + "<br />" + + $('#final').html("<?=$pkg_wait_txt?>" + "<br />" + "<?=gettext("(Some packages may take several minutes!)")?>"); } else { - $('#final').html("Please wait while the reinstallation of all packages completes." + "<br />" + + $('#final').html("<?=gettext('Please wait while the reinstallation of all packages completes.')?>" + "<br />" + "<?=gettext("(Some packages may take several minutes!)")?>"); } $('#final').show(); @@ -636,7 +646,7 @@ function scrollToBottom() { $('#output').scrollTop($('#output')[0].scrollHeight); } -var timeoutmsg = '<h4>Rebooting<br />Page will automatically reload in '; +var timeoutmsg = '<h4>' + '<?=gettext('Rebooting')?>' + '<br />' + 'Page will automatically reload in '; var time = 0; function checkonline() { @@ -656,7 +666,7 @@ function startCountdown() { time--; } else { time = "<?=$guiretry?>"; - timeoutmsg = '<h4>Not yet ready<br />Retrying in another '; + timeoutmsg = '<h4>' + '<?=gettext('Not yet ready')?>' + '<br />Retrying in another '; checkonline(); } }, 1000); |