Skip to content

Commit

Permalink
Add i18n support for lime-webui
Browse files Browse the repository at this point in the history
Add Spanish translation

Signed-off-by: Pau Escrich <p4u@dabax.net>
  • Loading branch information
p4u committed Mar 9, 2017
1 parent 56893fb commit fcd147f
Show file tree
Hide file tree
Showing 19 changed files with 2,206 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/lime-webui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP)
GIT_COMMIT_DATE:=$(shell git log -n 1 --pretty=%ad --date=short . )
GIT_COMMIT_TSTAMP:=$(shell git log -n 1 --pretty=%at . )

LIME_CODENAME:=bigbang
LIME_CODENAME:=communitychaos

include $(INCLUDE_DIR)/package.mk

Expand All @@ -35,13 +35,14 @@ endef
define Build/Prepare
@rm -rf $(PKG_BUILD_DIR) || true
mkdir -p $(PKG_BUILD_DIR)
./build_i18n.sh
endef

define Build/Configure
endef

define Build/Compile
@cp -r ./src/. $(PKG_BUILD_DIR)/
@cp -r ./luasrc/. $(PKG_BUILD_DIR)/
@find $(PKG_BUILD_DIR)/ -type f -name "*.lua" -exec sed -i '/^--!.*/d' {} \;
endef

Expand All @@ -50,10 +51,12 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/lime
$(INSTALL_DIR) $(1)/www/luci-static/resources/lime
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(CP) $(PKG_BUILD_DIR)/model/* $(1)/usr/lib/lua/luci/model/cbi/lime/
$(CP) $(PKG_BUILD_DIR)/controller/* $(1)/usr/lib/lua/luci/controller/
$(CP) $(PKG_BUILD_DIR)/view/* $(1)/usr/lib/lua/luci/view/lime/
$(CP) $(PKG_BUILD_DIR)/static/* $(1)/www/luci-static/resources/lime/
$(CP) $(PKG_BUILD_DIR)/i18n/* $(1)/usr/lib/lua/luci/i18n/
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
9 changes: 9 additions & 0 deletions packages/lime-webui/build_i18n.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
make -C po2lmo/ po2lmo
mkdir -p luasrc/i18n 2>/dev/null
for l in $(cd po; ls); do
for f in $(cd po/$l; ls *.po); do
b=$(basename -s po po/$l/$f)
./po2lmo/po2lmo po/$l/$f luasrc/i18n/${b}${l}.lmo
done
done
128 changes: 128 additions & 0 deletions packages/lime-webui/i18n-scan.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/perl

use strict;
use warnings;
use Text::Balanced qw(extract_bracketed extract_delimited extract_tagged);

@ARGV >= 1 || die "Usage: $0 <source direcory>\n";


my %stringtable;

sub dec_lua_str
{
my $s = shift;
$s =~ s/[\s\n]+/ /g;
$s =~ s/\\n/\n/g;
$s =~ s/\\t/\t/g;
$s =~ s/\\(.)/$1/g;
$s =~ s/^ //;
$s =~ s/ $//;
return $s;
}

sub dec_tpl_str
{
my $s = shift;
$s =~ s/-$//;
$s =~ s/[\s\n]+/ /g;
$s =~ s/^ //;
$s =~ s/ $//;
$s =~ s/\\/\\\\/g;
return $s;
}


if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
{
while( defined( my $file = readline F ) )
{
chomp $file;

if( open S, "< $file" )
{
local $/ = undef;
my $raw = <S>;
close S;


my $text = $raw;

while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
{
( my $code, $text ) = extract_bracketed($text, q{('")});

$code =~ s/\\\n/ /g;
$code =~ s/^\([\n\s]*//;
$code =~ s/[\n\s]*\)$//;

my $res = "";
my $sub = "";

if( $code =~ /^['"]/ )
{
while( defined $sub )
{
( $sub, $code ) = extract_delimited($code, q{'"}, q{\s*(?:\.\.\s*)?});

if( defined $sub && length($sub) > 2 )
{
$res .= substr $sub, 1, length($sub) - 2;
}
else
{
undef $sub;
}
}
}
elsif( $code =~ /^(\[=*\[)/ )
{
my $stag = quotemeta $1;
my $etag = $stag;
$etag =~ s/\[/]/g;

( $res ) = extract_tagged($code, $stag, $etag);

$res =~ s/^$stag//;
$res =~ s/$etag$//;
}

$res = dec_lua_str($res);
$stringtable{$res}++ if $res;
}


$text = $raw;

while( $text =~ s/ ^ .*? <% -? [:_] /<%/sgx )
{
( my $code, $text ) = extract_tagged($text, '<%', '%>');

if( defined $code )
{
$code = dec_tpl_str(substr $code, 2, length($code) - 4);
$stringtable{$code}++;
}
}
}
}

close F;
}


if( open C, "| msgcat -" )
{
printf C "msgid \"\"\nmsgstr \"Content-Type: text/plain; charset=UTF-8\"\n\n";

foreach my $key ( sort keys %stringtable )
{
if( length $key )
{
$key =~ s/"/\\"/g;
printf C "msgid \"%s\"\nmsgstr \"\"\n\n", $key;
}
}

close C;
}
File renamed without changes.
File renamed without changes
File renamed without changes.
111 changes: 111 additions & 0 deletions packages/lime-webui/po/es/lime-webui.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"

msgid "About"
msgstr "Sobre"

msgid "Access Point ESSID (usually name of your network)"
msgstr "ESSID del punto de acceso (normalmente nombre de la red)"

msgid "Advanced"
msgstr "Avanzado"

msgid "Channel 2.4 GHz"
msgstr "Canal 2.4GHz"

msgid "Channel 5 GHz"
msgstr "Canal 5GHz"

msgid "Community name"
msgstr "Nombre de la comunidad"

msgid "Contact"
msgstr "Contacto"

msgid "Contact information"
msgstr "Información de contacto"

msgid "Country code"
msgstr "Código del país"

msgid "Country code used for WiFi radios"
msgstr "Código del país usado para las radios WiFi"

msgid "Default channel used for 2.4 GHz radios"
msgstr "Canal por defecto usado para las radios de 2.4GHz"

msgid "Default channel used for 5 GHz radios"
msgstr "Canal por defecto usado para las radios de 5GHz"

msgid "Email"
msgstr "Correo"

msgid "General"
msgstr "General"

msgid "Hostname"
msgstr "Nombre de la máquina"

msgid "Latitude"
msgstr "Latitud"

msgid "Latitude (this can be also configured in location tab)"
msgstr "Latitud (puede ser configurada también en la sección Localización)"

msgid "Location"
msgstr "Localización"

msgid "Logout"
msgstr "Salir"

msgid "Longitude"
msgstr "Longitud"

msgid "Longitude (this can be also configured in location tab)"
msgstr "Longitud (puede ser configurada también en la sección Localización)"

msgid "Main IPv4"
msgstr "Dirección principal IPv4"

msgid "Main IPv6"
msgstr "Dirección principal IPv6"

msgid "Map location"
msgstr "Localización en mapa"

msgid "Mesh BSSID"
msgstr "BSSID de la Mesh"

msgid "Name"
msgstr "Nombre"

msgid "Name for this node"
msgstr "Nombre para este nodo"

msgid "Network SSID"
msgstr "SSID de la red"

msgid "Simple Config"
msgstr "Configuración simple"

msgid "The BSSID (WiFi network identifier) used for the mesh network"
msgstr "El BSSID (identificador de la red WiFi) usado para la mesh"

msgid ""
"The main IPv4 configured for this node, with slash notation (for ex. "
"1.2.3.4/24)"
msgstr "La IPv4 principal para este nodo, con notación de barra (p.e 1.2.3.4/24)"

msgid ""
"The main IPv6 configured for this node, with slash notation (for ex. 2001:"
"db8::1/64)"
msgstr "La IPv6 principal para este nodo, con notación de barra (p.e 2001:db8::1/64)"

msgid "The name of your network community"
msgstr "Nombre para la red comunitaria"

msgid "Your email (not required)"
msgstr "Tu correo electrónico (no obligatorio)"

msgid "Your name or alias (not required)"
msgstr "Tu nombre o alias (no obligatorio)"
21 changes: 21 additions & 0 deletions packages/lime-webui/po2lmo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(FPIC) -c -o $@ $<

clean:
rm -f po2lmo parser.so version.lua *.o

po2lmo: po2lmo.o template_lmo.o
$(CC) $(LDFLAGS) -o $@ $^

parser.so: template_parser.o template_utils.o template_lmo.o template_lualib.o
$(CC) $(LDFLAGS) -shared -o $@ $^

version.lua:
./mkversion.sh $@ $(LUCI_VERSION) "$(LUCI_GITBRANCH)"

compile: parser.so version.lua

install: compile
mkdir -p $(DESTDIR)/usr/lib/lua/luci/template
cp parser.so $(DESTDIR)/usr/lib/lua/luci/template/parser.so
cp version.lua $(DESTDIR)/usr/lib/lua/luci/version.lua
24 changes: 24 additions & 0 deletions packages/lime-webui/po2lmo/mkversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

cat <<EOF > $1
local pcall, dofile, _G = pcall, dofile, _G
module "luci.version"
if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
distname = ""
distversion = _G.DISTRIB_DESCRIPTION
if _G.DISTRIB_REVISION then
distrevision = _G.DISTRIB_REVISION
if not distversion:find(distrevision,1,true) then
distversion = distversion .. " " .. distrevision
end
end
else
distname = "OpenWrt"
distversion = "Development Snapshot"
end
luciname = "${3:-LuCI}"
luciversion = "${2:-Git}"
EOF

0 comments on commit fcd147f

Please sign in to comment.