luci-app-advanced-reboot: improve localization by moving from translate to translatef 3877/head
authorStan Grishin <stangri@melmac.net>
Sat, 11 Apr 2020 01:11:26 +0000 (01:11 +0000)
committerStan Grishin <stangri@melmac.net>
Sat, 11 Apr 2020 01:11:26 +0000 (01:11 +0000)
Signed-off-by: Stan Grishin <stangri@melmac.net>
applications/luci-app-advanced-reboot/Makefile
applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua
applications/luci-app-advanced-reboot/po/templates/advanced-reboot.pot
applications/luci-app-advanced-reboot/root/etc/uci-defaults/40_luci-advanced-reboot [new file with mode: 0644]

index f6882b2c02691d462c89b303fe01deb429a8a154..e119e6acc23f7a4bf6aef2262990a451a65e4e92 100644 (file)
@@ -13,7 +13,7 @@ LUCI_DESCRIPTION:=Provides Web UI (found under System/Advanced Reboot) to reboot
 
 LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full
 LUCI_PKGARCH:=all
-PKG_RELEASE:=51
+PKG_RELEASE:=52
 
 include ../../luci.mk
 
index 512626351f722842b1e1a3e14d8afe594cf8dfd6..4b651a9df049f595bde9518dc4dd770b357daeb1 100644 (file)
@@ -42,7 +42,7 @@ function get_partition_os_info(op_ubi)
                        cp_info = util.trim(util.exec('. /etc/os-release && echo "$OPENWRT_RELEASE"'))
                end 
        end
-       logger(i18n.translate("attempting to mount alternative partition") .. " (mtd" .. tostring(op_ubi) .. ")")
+       logger(i18n.translatef("attempting to mount alternative partition (mtd%s)", tostring(op_ubi))
        alt_partition_unmount(op_ubi)
        alt_partition_mount(op_ubi)
        if fs.access("/alt/rom/etc/os-release") then
@@ -51,7 +51,7 @@ function get_partition_os_info(op_ubi)
                        op_info = util.trim(util.exec('. /alt/rom/etc/os-release && echo "$OPENWRT_RELEASE"'))
                end 
        end
-       logger(i18n.translate("attempting to unmount alternative partition") .. " (mtd" .. tostring(op_ubi) .. ")")
+       logger(i18n.translatef("attempting to unmount alternative partition (mtd%s)", tostring(op_ubi))
        alt_partition_unmount(op_ubi)
        return cp_info, op_info
 end
@@ -176,7 +176,7 @@ function action_template()
                                bev1p2=bev1p2,
                                p2_os=p2_os,
                                current_partition=current_partition,
-                               errorMessage = errorMessage})
+                               errorMessage=errorMessage})
 end
 
 function action_reboot()
@@ -209,28 +209,28 @@ function action_altreboot()
                        if bev1 then
                                curEnvSetting = tonumber(util.trim(util.exec("fw_printenv -n " .. bev1)))
                                if not curEnvSetting then
-                                       errorMessage = errorMessage .. i18n.translate("Unable to obtain firmware environment variable") .. ": " .. bev1 .. ". "
-                                       util.perror(i18n.translate("Unable to obtain firmware environment variable") .. ": " .. bev1 .. ".")
+                                       errorMessage = errorMessage .. i18n.translatef("Unable to obtain firmware environment variable: %s.", bev1)
+                                       util.perror(i18n.translatef("Unable to obtain firmware environment variable: %s.", bev1))
                                else
                                        newEnvSetting = curEnvSetting == bev1p1 and bev1p2 or bev1p1
                                        errorCode = sys.call("fw_setenv " .. bev1 .. " " .. newEnvSetting)
                                                if errorCode ~= 0 then
-                                                       errorMessage = errorMessage or "" .. i18n.translate("Unable to set firmware environment variable") .. ": " .. bev1 .. " " .. i18n.translate("to") .. " " .. newEnvSetting .. ". "
-                                                       util.perror(i18n.translate("Unable to set firmware environment variable") .. ": " .. bev1 .. " " .. i18n.translate("to") .. " " .. newEnvSetting .. ".")
+                                                       errorMessage = errorMessage or "" .. i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev1, newEnvSetting)
+                                                       util.perror(i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev1, newEnvSetting))
                                                end
                                end
                        end
                        if bev2 then
                                curEnvSetting = util.trim(util.exec("fw_printenv -n " .. bev2))
                                if not curEnvSetting then
-                                       errorMessage = errorMessage or "" .. i18n.translate("Unable to obtain firmware environment variable") .. ": " .. bev2 .. ". "
-                                       util.perror(i18n.translate("Unable to obtain firmware environment variable") .. ": " .. bev2 .. ".")
+                                       errorMessage = errorMessage or "" .. i18n.translatef("Unable to obtain firmware environment variable: %s.", bev2)
+                                       util.perror(i18n.translatef("Unable to obtain firmware environment variable: %s.", bev2))
                                else
                                        newEnvSetting = curEnvSetting == bev2p1 and bev2p2 or bev2p1
                                        errorCode = sys.call("fw_setenv " .. bev2 .. " '" .. newEnvSetting .. "'")
                                        if errorCode ~= 0 then
-                                               errorMessage = errorMessage or "" .. i18n.translate("Unable to set firmware environment variable") .. ": " .. bev2 .. " " .. i18n.translate("to") .. " " .. newEnvSetting .. ". "
-                                               util.perror(i18n.translate("Unable to set firmware environment variable") .. ": " .. bev2 .. " " .. i18n.translate("to") .. " " .. newEnvSetting .. ".")
+                                               errorMessage = errorMessage or "" .. i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev2, newEnvSetting)
+                                               util.perror(i18n.translatef("Unable to set firmware environment variable: %s to %s.", bev2, newEnvSetting))
                                        end
                                end
                        end
@@ -245,8 +245,8 @@ function action_altreboot()
                                if zyxelNewBootFlag then
                                        errorCode = sys.call("printf \"" .. zyxelNewBootFlag .. "\" >" .. zyxelFlagPartition )
                                        if errorCode ~= 0 then
-                                               errorMessage = errorMessage or "" .. i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ". "
-                                               util.perror(i18n.translate("Unable to set Dual Boot Flag Partition entry for partition") .. ": " .. zyxelFlagPartition .. ".")
+                                               errorMessage = errorMessage or "" .. i18n.translatef("Unable to set Dual Boot Flag Partition entry for partition: %s.", zyxelFlagPartition)
+                                               util.perror(i18n.translatef("Unable to set Dual Boot Flag Partition entry for partition: %s.", zyxelFlagPartition))
                                        end
                                end
                        end
index 73173319c579b2480d2196153e4af87cd8a4b737..6aabe66a5a935456e49dd3f38b11a39e2b0ee72c 100644 (file)
@@ -143,19 +143,19 @@ msgstr ""
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:213
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:226
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:227
-msgid "Unable to obtain firmware environment variable"
+msgid "Unable to obtain firmware environment variable: %s."
 msgstr ""
 
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:248
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:249
-msgid "Unable to set Dual Boot Flag Partition entry for partition"
+msgid "Unable to set Dual Boot Flag Partition entry for partition: %s."
 msgstr ""
 
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:218
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:219
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:232
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:233
-msgid "Unable to set firmware environment variable"
+msgid "Unable to set firmware environment variable: %s to %s."
 msgstr ""
 
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:118
@@ -205,16 +205,9 @@ msgid "Warning: Unable to obtain device information!"
 msgstr ""
 
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:45
-msgid "attempting to mount alternative partition"
+msgid "attempting to mount alternative partition (mtd%s)"
 msgstr ""
 
 #: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:54
-msgid "attempting to unmount alternative partition"
-msgstr ""
-
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:218
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:219
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:232
-#: applications/luci-app-advanced-reboot/luasrc/controller/advanced_reboot.lua:233
-msgid "to"
+msgid "attempting to unmount alternative partition (mtd%s)"
 msgstr ""
diff --git a/applications/luci-app-advanced-reboot/root/etc/uci-defaults/40_luci-advanced-reboot b/applications/luci-app-advanced-reboot/root/etc/uci-defaults/40_luci-advanced-reboot
new file mode 100644 (file)
index 0000000..e1a8f1e
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+rm -rf /var/luci-modulecache/; rm -f /var/luci-indexcache;
+exit 0
+