Browse Source

Update packages to work with gluon 2018.1.x

* Substitute luci.jsonc with jsonc
* Migrate translations to new namespaces
* Plugins for the config-mode must be located unter config-mode, not web
* Some cosmetic changes in the Makefiles to get translations generated
Michael Schwarz 6 months ago
parent
commit
c3d0e1398b

+ 1 - 20
ffho-config-mode-site-select/Makefile

@@ -7,8 +7,6 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 include $(TOPDIR)/../package/gluon.mk
 
-PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
-
 define Package/ffho-config-mode-site-select
   SECTION:=ffho
   CATEGORY:=Site-select
@@ -17,21 +15,4 @@ define Package/ffho-config-mode-site-select
   MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 endef
 
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Configure
-endef
-
-define Build/Compile
-	$(call GluonBuildI18N,ffho-config-mode-site-select,i18n)
-	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
-endef
-
-define Package/ffho-config-mode-site-select/install
-	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(call GluonInstallI18N,ffho-config-mode-site-select,$(1))
-endef
-
-$(eval $(call BuildPackage,ffho-config-mode-site-select))
+$(eval $(call BuildPackageGluon,$(PKG_NAME)))

+ 9 - 0
ffho-config-mode-site-select/i18n/de.po

@@ -10,5 +10,14 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
+msgid ""
+"Here you have the possibility of selecting the region in which "
+"your node is placed. Please keep in mind that your router "
+"connects only with the mesh of the selected region."
+msgstr ""
+"Hier hast du die Möglichkeit die Region, in der sich dein "
+"Knoten befindet, auszuwählen. Bitte denke daran, dass dein Router "
+"sich nur mit dem Netz der ausgewählten Region verbindet."
+
 msgid "Region"
 msgstr "Region"

+ 6 - 0
ffho-config-mode-site-select/i18n/ffho-config-mode-site-select.pot

@@ -1,5 +1,11 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=UTF-8"
 
+msgid ""
+"Here you have the possibility of selecting the region in which your node is "
+"placed. Please keep in mind that your router connects only with the mesh of "
+"the selected region."
+msgstr ""
+
 msgid "Region"
 msgstr ""

+ 9 - 2
ffho-config-mode-site-select/luasrc/lib/gluon/config-mode/wizard/0200-site-select.lua

@@ -3,8 +3,15 @@ return function(form, uci)
 	local tools = require 'gluon.site_generate'
 
 	local sites = tools.get_config('/lib/gluon/site-select/sites.json')
-	
-	local s = form:section(Section, nil, translate('gluon-config-mode:site-select'))
+
+	local site_i18n = i18n 'gluon-site'
+	local pkg_i18n = i18n 'ffho-config-mode-site-select'
+	local help = site_i18n._translate('gluon-config-mode:site-select') or pkg_i18n.translate(
+		'Here you have the possibility of selecting the region in which '
+		.. 'your node is placed. Please keep in mind that your router '
+		.. 'connects only with the mesh of the selected region.'
+	)
+	local s = form:section(Section, nil, help)
 
 	local o = s:option(ListValue, 'community', translate('Region'))
 	o.optional = false

+ 2 - 15
ffho-site-generate/luasrc/usr/lib/lua/gluon/site_generate.lua

@@ -1,26 +1,13 @@
 #!/usr/bin/lua
 
 local uci = require('simple-uci').cursor()
-local json =  require 'luci.jsonc'
+local json =  require 'jsonc'
 local sites_json = '/lib/gluon/site-select/sites.json'
 
 module('gluon.site_generate', package.seeall)
 
 function get_config(file)
-  local decoder = json.new()
-  local sink = decoder:sink()
-
-  local f = assert(io.open(file))
-
-  while true do
-    local chunk = f:read(2048)
-    if not chunk or chunk:len() == 0 then break end
-    sink(chunk)
-  end
-
-  f:close()
-
-  return assert(decoder:get())
+  return assert(json.load(sites_json))
 end
 
 function get_list()

+ 1 - 20
ffho-web-ap-timer/Makefile

@@ -7,8 +7,6 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 include $(TOPDIR)/../package/gluon.mk
 
-PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
-
 define Package/ffho-web-ap-timer
   SECTION:=ffho
   CATEGORY:=FFHO
@@ -17,21 +15,4 @@ define Package/ffho-web-ap-timer
   MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 endef
 
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Configure
-endef
-
-define Build/Compile
-	$(call GluonBuildI18N,ffho-web-ap-timer,i18n)
-	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
-endef
-
-define Package/ffho-web-ap-timer/install
-	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(call GluonInstallI18N,ffho-web-ap-timer,$(1))
-endef
-
-$(eval $(call BuildPackage,ffho-web-ap-timer))
+$(eval $(call BuildPackageGluon,$(PKG_NAME)))

+ 27 - 3
ffho-web-ap-timer/i18n/de.po

@@ -1,8 +1,32 @@
 msgid ""
-msgstr "Content-Type: text/plain; charset=UTF-8"
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2017-06-24 23:00+0200\n"
+"Last-Translator:  <freifunk@kb-light.de>\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "You can setup the AP Timer here"
-msgstr "Hier kannst du den AP-Timer konfigurieren"
+msgid "AP Timer"
+msgstr "AP Timer"
 
 msgid "Daily"
 msgstr "Täglich"
+
+msgid "Enabled"
+msgstr "Aktiviert"
+
+msgid "OFF"
+msgstr "Aus"
+
+msgid "ON"
+msgstr "An"
+
+msgid "Type"
+msgstr "Typ"
+
+msgid "You can setup the AP Timer here"
+msgstr "Hier kannst du den AP-Timer konfigurieren"

+ 16 - 1
ffho-web-ap-timer/i18n/ffho-web-ap-timer.pot

@@ -1,8 +1,23 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=UTF-8"
 
-msgid "You can setup the AP Timer here"
+msgid "AP Timer"
 msgstr ""
 
 msgid "Daily"
 msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
+msgid "OFF"
+msgstr ""
+
+msgid "ON"
+msgstr ""
+
+msgid "Type"
+msgstr ""
+
+msgid "You can setup the AP Timer here"
+msgstr ""

+ 1 - 0
ffho-web-ap-timer/luasrc/lib/gluon/web/controller/admin/ap-timer.lua

@@ -1 +1,2 @@
+package 'ffho-web-ap-timer'
 entry({"admin", "ap-timer"}, model("admin/ap-timer"), _("AP Timer"), 30)

+ 8 - 6
ffho-web-ap-timer/luasrc/lib/gluon/web/model/admin/ap-timer.lua

@@ -1,5 +1,7 @@
 local uci = require('simple-uci').cursor()
 
+pkg_i18n = i18n 'ffho-web-ap-timer'
+
 if not uci:get('ap-timer', 'settings') then
 	uci:section('ap-timer', 'ap-timer', 'settings')
 	uci:save('ap-timer')
@@ -10,29 +12,29 @@ if not uci:get('ap-timer', 'all') then
 	uci:save('ap-timer')
 end
 
-local f = Form(translate('AP Timer'), translate(
+local f = Form(pkg_i18n.translate('AP Timer'), pkg_i18n.translate(
 	'You can setup the AP Timer here'))
 
 local s = f:section(Section)
 
-enabled = s:option(Flag, 'enabled', translate('Enabled'))
+enabled = s:option(Flag, 'enabled', pkg_i18n.translate('Enabled'))
 enabled.default = uci:get_bool('ap-timer', 'settings', 'enabled')
 enabled.optional = false
 function enabled:write(data)
 	uci:set('ap-timer', 'settings', 'enabled', data)
 end
 
-local timer_type = s:option(ListValue, 'type', translate('Type'))
+local timer_type = s:option(ListValue, 'type', pkg_i18n.translate('Type'))
 timer_type.default = uci:get('ap-timer', 'settings', 'type')
 timer_type:depends(enabled, true)
-timer_type:value('day', translate('Daily'))
+timer_type:value('day', pkg_i18n.translate('Daily'))
 function timer_type:write(data)
 	uci:set('ap-timer', 'settings', 'type', data)
 end
 
 local s = f:section(Section)
 
-o = s:option(DynamicList, 'on', translate('ON'))
+o = s:option(DynamicList, 'on', pkg_i18n.translate('ON'))
 o.default = uci:get_list('ap-timer', 'all', 'on')
 o.placeholder = '06:30'
 o:depends(timer_type, 'day')
@@ -42,7 +44,7 @@ function o:write(data)
 	uci:set_list('ap-timer', 'all', 'on', data)
 end
 
-o = s:option(DynamicList, 'off', translate('OFF'))
+o = s:option(DynamicList, 'off', pkg_i18n.translate('OFF'))
 o.default = uci:get_list('ap-timer', 'all', 'off')
 o.placeholder = '23:00'
 o:depends(timer_type, 'day')

+ 1 - 21
ffho-web-autoupdater/Makefile

@@ -10,9 +10,6 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 include $(TOPDIR)/../package/gluon.mk
 
-PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
-
-
 define Package/ffho-web-autoupdater
   SECTION:=ffho
   CATEGORY:=FFHO
@@ -22,21 +19,4 @@ define Package/ffho-web-autoupdater
   PROVIDES:=gluon-web-autoupdater
 endef
 
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Configure
-endef
-
-define Build/Compile
-	$(call GluonBuildI18N,ffho-web-autoupdater,i18n)
-	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
-endef
-
-define Package/ffho-web-autoupdater/install
-	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(call GluonInstallI18N,ffho-web-autoupdater,$(1))
-endef
-
-$(eval $(call BuildPackage,ffho-web-autoupdater))
+$(eval $(call BuildPackageGluon,$(PKG_NAME)))

+ 1 - 0
ffho-web-autoupdater/luasrc/lib/gluon/web/controller/admin/autoupdater.lua

@@ -1 +1,2 @@
+package 'ffho-web-autoupdater'
 entry({"admin", "autoupdater"}, model("admin/autoupdater"), _("Automatic updates"), 80)

+ 6 - 4
ffho-web-autoupdater/luasrc/lib/gluon/web/model/admin/autoupdater.lua

@@ -13,17 +13,19 @@ local uci = require('simple-uci').cursor()
 local autoupdater = uci:get_first('autoupdater', 'autoupdater')
 local wifi_fallback = uci:get_first('autoupdater-wifi-fallback', 'autoupdater-wifi-fallback')
 
-local f = Form(translate('Automatic updates'))
+local pkg_i18n = i18n 'ffho-web-autoupdater'
+
+local f = Form(pkg_i18n.translate('Automatic updates'))
 local s = f:section(Section)
 local o
 
-o = s:option(Flag, 'enabled', translate('Enable'))
+o = s:option(Flag, 'enabled', pkg_i18n.translate('Enable'))
 o.default = uci:get_bool('autoupdater', autoupdater, 'enabled')
 function o:write(data)
 	uci:set('autoupdater', autoupdater, 'enabled', data)
 end
 
-o = s:option(ListValue, 'branch', translate('Branch'))
+o = s:option(ListValue, 'branch', pkg_i18n.translate('Branch'))
 uci:foreach('autoupdater', 'branch',
 	function (section)
 		o:value(section['.name'])
@@ -34,7 +36,7 @@ function o:write(data)
 	uci:set('autoupdater', autoupdater, 'branch', data)
 end
 
-o = s:option(Value, "minute", translate("Minute"), translate(
+o = s:option(Value, "minute", translate("Minute"), pkg_i18n.translate(
 	"This value forces the autoupdater to check for updates at the "
 	.. "specified minute. Normally there is no need to set this value "
 	.. "because it is selected automatically. You may want to set this to "