From cadeb9fd98e860c84658c84cdc0b3c050b7ee326 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 25 Jan 2016 22:59:56 +0545 Subject: 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. --- src/usr/local/www/pkg.php | 24 ++++++++--------- src/usr/local/www/pkg_edit.php | 5 ++-- src/usr/local/www/pkg_mgr.php | 2 +- src/usr/local/www/pkg_mgr_install.php | 50 +++++++++++++++++++++-------------- 4 files changed, 46 insertions(+), 35 deletions(-) (limited to 'src') 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 ""; - echo "Filter by: "; + echo gettext("Filter by: "); $isfirst = true; for ($char = 65; $char < 91; $char++) { if (!$isfirst) { @@ -362,7 +362,7 @@ if ($savemsg) { echo ""; echo ""; if ($field['sortablefields']) { - echo "Filter field: "; foreach ($field['sortablefields']['item'] as $si) { if ($si['name'] == $_REQUEST['pkg_filter_type']) { $SELECTED = "selected"; @@ -374,7 +374,7 @@ if ($savemsg) { echo ""; } if ($include_filtering_inputbox) { - echo "  Filter text: "; + echo "  " . gettext("Filter text: ") . ""; } echo " "; } @@ -405,8 +405,8 @@ if ($savemsg) { echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo " - +
Displaying page $page of $totalpagesRows per page: " . sprintf(gettext('Displaying page %1$s of %2$s'), $page, $totalpages) . "" . gettext("Rows per page: ") . "
 "> 
@@ -563,7 +563,7 @@ if ($savemsg) { } else if ($startdisplayingat > 1) { $final_footer .= ""; } - $final_footer .= "<< Previous page"; + $final_footer .= "<< " . gettext("Previous page") . ""; if ($tmppp + $display_maximum_rows > count($evaledvar)) { $endingrecord = count($evaledvar); } else { @@ -576,7 +576,7 @@ if ($savemsg) { if (($i+1) < count($evaledvar)) { $final_footer .= ""; } - $final_footer .= "Next page >>"; + $final_footer .= "" . gettext("Next page") . " >>"; $final_footer .= ""; $i = count($evaledvar); break; @@ -594,7 +594,7 @@ if ($savemsg) { '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); " class="btn btn-default btn-sm">
- Enter a search string or *nix regular expression to search package names and descriptions. +
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 %s will be reinstalled'), $pkgname); break; case 'delete': - $pkgtxt = 'removed'; + $pkgtxt = sprintf(gettext('Package %s will be removed'), $pkgname); break; + case 'installed': default: - $pkgtxt = $pkgmode; + $pkgtxt = sprintf(gettext('Package %s will be installed'), $pkgname); break; } ?> @@ -313,7 +314,7 @@ if ($input_errors) { - Package: will be upgraded from to . + ' . $pkgname . '', '' . $_GET['from'] . '', '' . $_GET['to'] . '')?> @@ -321,7 +322,7 @@ if ($input_errors) { - Package: will be . + . @@ -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('%1$s removal successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('%1$s removal failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the removal of %1$s completes.'), $pkgid); } else if (($_POST['mode'] == 'reinstallpkg') || ($_POST['mode'] == 'reinstallall')) { - $modetxt = gettext("reinstallation"); + $panel_heading_txt = gettext("Package reinstallation"); + $pkg_success_txt = sprintf(gettext('%1$s reinstallation successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('%1$s reinstallation failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the reinstallation of %1$s completes.'), $pkgid); } else { - $modetxt = gettext("installation"); + $panel_heading_txt = gettext("Package installation"); + $pkg_success_txt = sprintf(gettext('%1$s installation successfully completed'), $pkgid); + $pkg_fail_txt = sprintf(gettext('%1$s installation failed!'), $pkgid); + $pkg_wait_txt = sprintf(gettext('Please wait while the installation of %1$s completes.'), $pkgid); } if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): @@ -423,7 +437,7 @@ if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"):

-

+

@@ -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 ("" != "reinstallall") { if ("" == "firmware") { - $('#final').html("" + "System update" + " " + ""); + $('#final').html("" + "" + ""); } else { - $('#final').html("" + "" + " " + "" + " " + ""); + $('#final').html(""); } } else { $('#final').html(""); @@ -536,7 +546,7 @@ function show_failure() { $('#final').removeClass("alert-info"); $('#final').addClass("alert-danger"); if ("" != "reinstallall") { - $('#final').html("" + " " + "" + " " + ""); + $('#final').html(""); } else { $('#final').html(""); } @@ -547,10 +557,10 @@ function show_failure() { function show_info() { $('#final').addClass("alert-info"); if ("" != "reinstallall") { - $('#final').html("Please wait while the " + "" + " of " + "" + " " + "completes." + "
" + + $('#final').html("" + "
" + ""); } else { - $('#final').html("Please wait while the reinstallation of all packages completes." + "
" + + $('#final').html("" + "
" + ""); } $('#final').show(); @@ -636,7 +646,7 @@ function scrollToBottom() { $('#output').scrollTop($('#output')[0].scrollHeight); } -var timeoutmsg = '

Rebooting
Page will automatically reload in '; +var timeoutmsg = '

' + '' + '
' + 'Page will automatically reload in '; var time = 0; function checkonline() { @@ -656,7 +666,7 @@ function startCountdown() { time--; } else { time = ""; - timeoutmsg = '

Not yet ready
Retrying in another '; + timeoutmsg = '

' + '' + '
Retrying in another '; checkonline(); } }, 1000); -- cgit v1.1