Commit 2f1d85e2 authored by Franco Fichtner's avatar Franco Fichtner

lang: bootstrap by importing lang/ from core.git

Commit: c9330e3b6aaed
parents
XGETTEXT= xgettext -L PHP --from-code=UTF-8 -F --strict --debug
XGETTEXT_PL= xgettext.pl -P Locale::Maketext::Extract::Plugin::Volt \
-u -w -W
MSGMERGE= msgmerge -U -N --backup=off
MSGFMT= msgfmt --strict
PERL_DIR= /usr/local/lib/perl5/site_perl
PERL_NAME= Locale/Maketext/Extract/Plugin
LOCALEDIR= /usr/local/share/locale/%%LANG%%/LC_MESSAGES
# stable
LANGUAGES= de_DE fr_FR ja_JP zh_CN
# devel
LANGUAGES+= es_CO mn_MN nl_NL ru_RU
TEMPLATE= en_US
INSTALL=
MERGE=
PLIST=
PAGER?= less
all:
@cat ${.CURDIR}/README.md | ${PAGER}
.for LANG in ${LANGUAGES}
${LANG}DIR= ${LOCALEDIR:S/%%LANG%%/${LANG}/g}
install-${LANG}:
@mkdir -p ${DESTDIR}${${LANG}DIR}
${MSGFMT} -o ${DESTDIR}${${LANG}DIR}/OPNsense.mo ${LANG}.po
clean-${LANG}:
@rm -f ${DESTDIR}${${LANG}DIR}/OPNsense.mo
plist-${LANG}:
@echo ${${LANG}DIR}/OPNsense.mo
merge-${LANG}:
${MSGMERGE} ${LANG}.po ${TEMPLATE}.pot
# strip stale translations
sed -i '' -e '/^#~.*/d' ${LANG}.po
INSTALL+= install-${LANG}
CLEAN+= clean-${LANG}
PLIST+= plist-${LANG}
MERGE+= merge-${LANG}
.endfor
${TEMPLATE}:
@cp ${.CURDIR}/Volt.pm ${PERL_DIR}/${PERL_NAME}/
@: > ${TEMPLATE}.pot
cd ${.CURDIR}/.. && \
${XGETTEXT_PL} -D src -p ${.CURDIR} -o ${TEMPLATE}.pot
cd ${.CURDIR}/.. && find src lang/dynamic/helpers | \
xargs ${XGETTEXT} -j -o ${.CURDIR}/${TEMPLATE}.pot
template: ${TEMPLATE}
install: ${INSTALL}
clean: ${CLEAN}
plist: ${PLIST}
merge: ${MERGE}
dynamic:
@${.CURDIR}/dynamic/collect.py ${.CURDIR}/..
.PHONY: ${INSTALL} ${PLIST} ${MERGE} ${TEMPLATE} dynamic
OPNsense language translation kit
=================================
The kit requires additional tools in order to properly extract strings
from the source code. You'll need to run this once locally:
# pkg install gettext-tools p5-Locale-Maketext-Lexicon python27
Regenerate dynamic strings that can't be found in the template
generation step (XML contents, etc.):
# make dynamic
Regenerate the translation template using:
# make template
Merge the latest template changes into the actual translations:
# make merge
Remove the compiled translation files from the system/chroot:
# make clean
The build system will automatically pick up all registered languages.
package Locale::Maketext::Extract::Plugin::Volt;
$Locale::Maketext::Extract::Plugin::Volt::VERSION = '1.00';
use strict;
use base qw(Locale::Maketext::Extract::Plugin::Base);
# ABSTRACT: Volt template parser
sub file_types {
return qw( volt );
}
sub extract {
my $self = shift;
local $_ = shift;
my $line = 1;
# Volt Template:
$line = 1;
pos($_) = 0;
while (m/\G(.*?(?<!\{)\{\{(?!\{)\s*lang\._\('(.*?)'\)\s*\}\})/sg) {
my ( $vars, $str ) = ( '', $2 );
$line += ( () = ( $1 =~ /\n/g ) ); # cryptocontext!
$self->add_entry( $str, $line, $vars );
}
}
1;
__END__
This diff is collapsed.
#!/usr/bin/env python2.7
"""
Copyright (c) 2015 Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
"""
__author__ = 'Ad Schellevis'
import os.path
import glob
import importlib
import sys
if len(sys.argv) < 2:
print 'Usage: collect.py rootdir'
sys.exit(1)
# get source location (root of core package)
OPNsenseRoot=sys.argv[1] + '/src'
# create target location
targetPath=sys.argv[1] + '/lang/dynamic/helpers'
if len(glob.glob(targetPath)) == 0:
os.mkdir(targetPath)
# load default output template
templateText = open('%s/template.txt'%'/'.join(os.path.realpath(__file__).split('/')[:-1]),'r').read()
for filename in glob.glob('%s/plugins/*.py'%'/'.join(os.path.realpath(__file__).split('/')[:-1])):
modulename = os.path.basename(filename)[:-3]
lang = importlib.import_module('plugins.%s'%modulename)
if hasattr(lang,'getTranslations'):
# open filehandle for collected plugin
fOut=open('%s/%s.php'%(targetPath,modulename),'w')
fOut.write(templateText)
# collect and sort tags
translations = list()
for textValue in lang.getTranslations(OPNsenseRoot):
translations.append(textValue)
translations.sort()
# fill with gettext tags
for textValue in translations:
line="echo gettext('%s');\n"%(unicode(textValue).replace("'","\\'"))
fOut.write(line)
fOut.close()
This diff is collapsed.
<?php
/**
* Copyright (C) 2015 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
*
* Language support, autogenerated file
*
*/
echo gettext('Enable this zone');
echo gettext('Internal number used for this zone');
echo gettext('Select interface(s) to enable for captive portal.');
echo gettext('Select authentication methods to use, leave empty for no authentication needed.');
echo gettext('Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Enter 0 to disable idle timeout.');
echo gettext('Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. Enter 0 to disable hard timeout (not recommended unless an idle timeout is set).');
echo gettext('If this option is set, users can login on multiple machines at once. If disabled subsequent logins will cause machines previously logged in with the same username to be disconnected.');
echo gettext('If provided, all traffic will be transmitted over an HTTPS connection to protect against eavesdroppers.');
echo gettext('Hostname (of this machine) to redirect login page to, leave blank to use this interface IP address, otherwise make sure the client can access DNS to resolve this location. When using a SSL certificate, make sure both this name and the cert name are equal.');
echo gettext('Avoid authentication for addresses and subnets in this list');
echo gettext('Avoid authentication for physical addresses in this list');
echo gettext('Use custom template package for user login');
echo gettext('Description to identify this zone.');
echo gettext('Select if job is enabled or not');
echo gettext('Enter the minutes for the job to act, can also be a comma separated list, * (each) or a range (ex. 10,20,30 or 10-30)');
echo gettext('Enter the hours for the job to act, can also be a comma separated list, * (each) or a range (ex. 10,11,12 or 10-12)');
echo gettext('Enter the days of the month for the job to act, can also be a comma separated list, * (each) or a range (ex. 1,20,28 or 1-28)');
echo gettext('Enter the months for the job to act, can also be a comma separated list, * (each) or a range (ex. 1,2,3 or 1-3)');
echo gettext('Enter the days of the week for the job to act, can also be a comma separated list, * (each) or a range (ex. 1,2,3 or 1-3)');
echo gettext('Select the command that needs to be executed at given time frame.');
echo gettext('Enter parameters for this job if required.');
echo gettext('Enter a description to explain what this job is intended for.');
echo gettext('set action to perform here, only used when in IPS mode');
echo gettext('enable IDS');
echo gettext('Select interface(s) to use.');
echo gettext('Select if job is enabled or not');
echo gettext('Enter a filename for storing the blacklist.');
echo gettext('Enter an url to fetch the blacklist from.');
echo gettext('Enter a description to explain what this blacklist is intended for.');
echo gettext('Enable or disable the proxy service.');
echo gettext('The port number where Squid sends and receives ICP queries to and from neighbor caches. Leave blank to disable (default). The standard UDP port for ICP is 3130.');
echo gettext('Enable access logging.');
echo gettext('Enable store logging.');
echo gettext('If set (default), Squid will include a Via header in requests and
replies as required by RFC2616.');
echo gettext('Select what to do with X-Forwarded for header.');
echo gettext('Suppress Squid version string info in HTTP headers and HTML error pages.');
echo gettext('Enter the cache memory size to use.');
echo gettext('Enter the storage size for the local cache (default is 100).');
echo gettext('Enter the number of first-level subdirectories for the local cache (default is 16).');
echo gettext('Enter the number of first-level subdirectories for the local cache (default is 256).');
echo gettext('Enable or disable traffic management.');
echo gettext('Enter the maxium size for downloads in kilobytes (leave empty to disable).');
echo gettext('Enter the maxium size for uploads in kilobytes (leave empty to disable).');
echo gettext('Enter the allowed overall bandtwith in kilobits per second (leave empty to disable).');
echo gettext('Enter the allowed per host bandwidth in kilobits per second (leave empty to disable).');
echo gettext('Select interface(s) the proxy will bind to.');
echo gettext('The port the proxy service will listen to.');
echo gettext('When enabled the subnets of the selected interfaces will be added to the allow access list.');
echo gettext('Select interface(s) the ftp proxy will bind to.');
echo gettext('The port the proxy service will listen to.');
echo gettext('Select Authentication method');
echo gettext('The prompt will be displayed in the authentication request window.');
echo gettext('The total number of authenticator processes to spawn.');
echo gettext('enable this pipe and it\'s related queues and rules');
echo gettext('Total bandwidth for this pipe');
echo gettext('number of dynamic queues, leave empty for default');
echo gettext('Description to identify this pipe.');
echo gettext('enable this queue and it\'s related rules');
echo gettext('connected pipe for this queue');
echo gettext('Weight of this queue (1..100), used to prioritize within a pipe. (1 is low, 100 is high)');
echo gettext('Description to identify this pipe.');
echo gettext('order in which the rule will be evaluated (lowest first)');
echo gettext('secondary interface, matches packets going traveling from interface (1) to interface (2).
');
echo gettext('source ip or network, examples 10.0.0.0/24, 10.0.0.1');
echo gettext('source port number or well known name (imap,imaps, http,https,...)');
echo gettext('destination ip or network, examples 10.0.0.0/24, 10.0.0.1');
echo gettext('destination port number or well known name (imap,imaps, http,https,...)');
echo gettext('matches incoming or outgoing packets or both (default)');
echo gettext('target pipe or queue');
This diff is collapsed.
"""
Copyright (c) 2015 Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
package : translate
function: collect acl translatable text
"""
__author__ = 'Ad Schellevis'
def getTranslations(root):
import json
filename='%s/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json'%root
aclMap = json.loads(open(filename).read())
for aclKey in aclMap.keys():
if aclMap[aclKey].has_key('descr'):
yield aclMap[aclKey]['descr']
"""
Copyright (c) 2015 Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
package : translate
function: collect controller translatable text
"""
__author__ = 'Ad Schellevis'
def recursiveParseForm(xmlNode):
for childNode in xmlNode:
for tag in recursiveParseForm(childNode):
yield tag
if xmlNode.tag == 'help':
yield xmlNode.text
def getTranslations(root):
import os
import xml.etree.ElementTree as ET
rootpath='%s/opnsense/mvc/app/controllers/'%root
for rootdir, dirs, files in os.walk(rootpath, topdown=False):
for name in files:
if name.lower()[-4:] == '.xml':
filename = '%s/%s'%(rootdir,name)
tree = ET.parse(filename)
rootObj = tree.getroot()
if rootObj.tag == 'form':
for tag in recursiveParseForm(rootObj):
yield tag
"""
Copyright (c) 2015 Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
package : translate
function: collect model translatable text
"""
__author__ = 'Ad Schellevis'
def recursiveParseModel(xmlNode):
for childNode in xmlNode:
for tag in recursiveParseModel(childNode):
yield tag
if xmlNode.tag == 'ValidationMessage':
yield xmlNode.text
def recursiveParseMenu(xmlNode):
for childNode in xmlNode:
for tag in recursiveParseMenu(childNode):
yield tag
if xmlNode.attrib.has_key('VisibleName'):
yield xmlNode.attrib['VisibleName']
else:
yield xmlNode.tag
def getTranslations(root):
import os
import xml.etree.ElementTree as ET
rootpath='%s/opnsense/mvc/app/models/'%root
for rootdir, dirs, files in os.walk(rootpath, topdown=False):
for name in files:
if name.lower()[-4:] == '.xml':
filename = '%s/%s'%(rootdir,name)
tree = ET.parse(filename)
rootObj = tree.getroot()
if rootObj.tag == 'model':
for tag in recursiveParseModel(rootObj):
yield tag
elif rootObj.tag == 'menu':
for tag in recursiveParseMenu(rootObj):
yield tag
<?php
/**
* Copyright (C) 2015 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
*
* Language support, autogenerated file
*
*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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