Commit e00e0359 authored by Franco Fichtner's avatar Franco Fichtner

template: collect all strings from all know directories

xgettext currently destroys part of the template (especially the header)
while generating and appending multiple times.  Need to investigate further.
parent 5936f3c7
...@@ -36,6 +36,10 @@ LOCALEDIR= /usr/local/share/locale/%%LANG%%/LC_MESSAGES ...@@ -36,6 +36,10 @@ LOCALEDIR= /usr/local/share/locale/%%LANG%%/LC_MESSAGES
LANGUAGES= de_DE es_CO fr_FR nl_NL ja_JP mn_MN ru_RU zh_CN LANGUAGES= de_DE es_CO fr_FR nl_NL ja_JP mn_MN ru_RU zh_CN
PLUGINSDIR?= /usr/plugins
COREDIR?= /usr/core
LANGDIR?= /usr/lang
TEMPLATE= en_US TEMPLATE= en_US
INSTALL= INSTALL=
MERGE= MERGE=
...@@ -64,13 +68,19 @@ CLEAN+= clean-${LANG} ...@@ -64,13 +68,19 @@ CLEAN+= clean-${LANG}
MERGE+= merge-${LANG} MERGE+= merge-${LANG}
.endfor .endfor
_PLUGINSDIRS!= ${MAKE} -C ${PLUGINSDIR} list
PLUGINSDIRS= ${_PLUGINSDIRS:S/^/${PLUGINSDIR}\//g}
${TEMPLATE}: ${TEMPLATE}:
@cp ${.CURDIR}/Volt.pm ${PERL_DIR}/${PERL_NAME}/ @cp ${.CURDIR}/Volt.pm ${PERL_DIR}/${PERL_NAME}/
@: > ${TEMPLATE}.pot @: > ${TEMPLATE}.pot
cd ${.CURDIR}/.. && \ .for ROOTDIR in ${PLUGINSDIRS} ${COREDIR}
${XGETTEXT_PL} -D src -p ${.CURDIR} -o ${TEMPLATE}.pot ${XGETTEXT_PL} -D ${ROOTDIR}/src -p ${.CURDIR} -o ${TEMPLATE}.pot
cd ${.CURDIR}/.. && find src lang/dynamic/helpers | \ find ${ROOTDIR}/src -print0 | \
xargs ${XGETTEXT} -j -o ${.CURDIR}/${TEMPLATE}.pot xargs -0 ${XGETTEXT} -j -o ${.CURDIR}/${TEMPLATE}.pot
.endfor
find ${LANGDIR}/dynamic/helpers -print0 | \
xargs -0 ${XGETTEXT} -j -o ${.CURDIR}/${TEMPLATE}.pot
template: ${TEMPLATE} template: ${TEMPLATE}
install: ${INSTALL} install: ${INSTALL}
...@@ -78,6 +88,6 @@ clean: ${CLEAN} ...@@ -78,6 +88,6 @@ clean: ${CLEAN}
merge: ${MERGE} merge: ${MERGE}
dynamic: dynamic:
@${.CURDIR}/dynamic/collect.py ${.CURDIR}/.. @${.CURDIR}/dynamic/collect.py ${PLUGINSDIRS} ${COREDIR}
.PHONY: ${INSTALL} ${MERGE} ${TEMPLATE} dynamic .PHONY: ${INSTALL} ${MERGE} ${TEMPLATE} dynamic
...@@ -36,11 +36,11 @@ if len(sys.argv) < 2: ...@@ -36,11 +36,11 @@ if len(sys.argv) < 2:
print 'Usage: collect.py rootdir' print 'Usage: collect.py rootdir'
sys.exit(1) sys.exit(1)
# get source location (root of core package) # get source locations
OPNsenseRoot=sys.argv[1] + '/src' RootPaths = sys.argv[1:]
# create target location # create target location
targetPath=sys.argv[1] + '/lang/dynamic/helpers' targetPath = 'dynamic/helpers'
if len(glob.glob(targetPath)) == 0: if len(glob.glob(targetPath)) == 0:
os.mkdir(targetPath) os.mkdir(targetPath)
...@@ -58,8 +58,9 @@ for filename in glob.glob('%s/plugins/*.py'%'/'.join(os.path.realpath(__file__). ...@@ -58,8 +58,9 @@ for filename in glob.glob('%s/plugins/*.py'%'/'.join(os.path.realpath(__file__).
# collect and sort tags # collect and sort tags
translations = list() translations = list()
for textValue in lang.getTranslations(OPNsenseRoot): for RootPath in RootPaths:
translations.append(textValue) for textValue in lang.getTranslations(RootPath + '/src'):
translations.append(textValue)
translations.sort() translations.sort()
# fill with gettext tags # fill with gettext tags
......
...@@ -32,8 +32,13 @@ __author__ = 'Ad Schellevis' ...@@ -32,8 +32,13 @@ __author__ = 'Ad Schellevis'
def getTranslations(root): def getTranslations(root):
import json import json
filename='%s/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json'%root filename='%s/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json'%root
aclMap = json.loads(open(filename).read())
try:
aclMap = json.loads(open(filename).read())
except IOError:
aclMap = dict()
for aclKey in aclMap.keys(): for aclKey in aclMap.keys():
if aclMap[aclKey].has_key('descr'): if aclMap[aclKey].has_key('descr'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment