config: Convert string update script to python and update
This commit is contained in:
parent
8cb792d0de
commit
a790d21492
|
@ -115,6 +115,7 @@ const char *txt[] = {
|
|||
_("Help"),
|
||||
_("About Enlightenment"),
|
||||
_("About this theme"),
|
||||
_("Theme menu"),
|
||||
_("Restart"),
|
||||
_("Log Out"),
|
||||
/* winops.menu */
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Script to extract localizable strings from config files
|
||||
# $ perl strings.pl *.cfg *.menu >strings.c
|
||||
|
||||
sub x() {
|
||||
|
||||
# actionclasses.cfg
|
||||
$TTT = 0;
|
||||
$TAT = 0;
|
||||
|
||||
if (/__TOOLTIP_TEXT\s+\"(.*)\"/) {
|
||||
# print " _(\"$1\"),\n"
|
||||
if ($ttt) {
|
||||
$ttt = "$ttt\\n$1";
|
||||
} else {
|
||||
$ttt = "$1";
|
||||
}
|
||||
$TTT = 1;
|
||||
} elsif (/__TOOLTIP_ACTION_TEXT\s+\"(.*)\"/) {
|
||||
# print " _(\"$1\"),\n";
|
||||
$tat = "$1";
|
||||
$TAT = 1;
|
||||
}
|
||||
|
||||
if (!($TTT) && $ttt) {
|
||||
print " _(\"$ttt\"),\n";
|
||||
$ttt = "";
|
||||
}
|
||||
|
||||
if (!($TAT) && $tat) {
|
||||
print " _(\"$tat\"),\n";
|
||||
$tat = "";
|
||||
}
|
||||
|
||||
# bindings.cfg
|
||||
$TDT = 0;
|
||||
|
||||
if (/^Tooltip\s+(.*)$/) {
|
||||
# print " _(\"$1\"),\n"
|
||||
if ($tdt) {
|
||||
$tdt = "$tdt\\n$1";
|
||||
} else {
|
||||
$tdt = "$1";
|
||||
}
|
||||
$TDT = 1;
|
||||
}
|
||||
|
||||
if (!($TDT) && $tdt) {
|
||||
print " _(\"$tdt\"),\n";
|
||||
$tdt = "";
|
||||
}
|
||||
|
||||
# menus.cfg
|
||||
if (/ADD_MENU_TITLE\s*\(\s*(\".*\")/) {
|
||||
$t = "$1";
|
||||
print " _($t),\n";
|
||||
}
|
||||
elsif (/ADD_.*MENU_TEXT_ITEM\s*\(\s*(\".*\"),/) {
|
||||
$t = "$1";
|
||||
print " _($t),\n";
|
||||
}
|
||||
|
||||
# *.menu
|
||||
if (/^"([^"]+)"/) {
|
||||
print " _(\"$1\"),\n";
|
||||
}
|
||||
}
|
||||
|
||||
# From e_gen_menu
|
||||
@sl = (
|
||||
"User Menus",
|
||||
"User Application List",
|
||||
"Applications",
|
||||
"Epplets",
|
||||
"Restart",
|
||||
"Log Out"
|
||||
);
|
||||
|
||||
#
|
||||
# Start
|
||||
#
|
||||
print "#define _(x) x\n\n";
|
||||
print "const char *txt[] = {\n";
|
||||
|
||||
for ($i=0; $i <= $#ARGV; $i++) {
|
||||
$f = $ARGV[$i];
|
||||
print "/* $f */\n";
|
||||
open F, $f;
|
||||
for (<F>) {
|
||||
x();
|
||||
}
|
||||
close $f;
|
||||
}
|
||||
|
||||
# Other strings.
|
||||
print "\n";
|
||||
foreach $s (@sl) {
|
||||
print " _(\"$s\"),\n";
|
||||
}
|
||||
|
||||
print "};\n";
|
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/python3
|
||||
#
|
||||
# Script to extract localizable strings from config files
|
||||
# $ (cd config && ./strings.py *.cfg *.menu >strings.c)
|
||||
|
||||
import sys
|
||||
|
||||
ttt = ''
|
||||
tat = ''
|
||||
tdt = ''
|
||||
|
||||
|
||||
def quote1(line):
|
||||
return line.split('"')[1]
|
||||
|
||||
def do_line_cfg(line):
|
||||
global ttt, tat
|
||||
global tdt
|
||||
|
||||
# actionclasses.cfg
|
||||
TTT = 0
|
||||
TAT = 0
|
||||
|
||||
if line.find('__TOOLTIP_TEXT') >= 0:
|
||||
txt = quote1(line)
|
||||
if ttt:
|
||||
ttt += '\\n' + txt
|
||||
else:
|
||||
ttt = txt
|
||||
TTT = 1
|
||||
elif line.find('__TOOLTIP_ACTION_TEXT') > 0:
|
||||
txt = quote1(line)
|
||||
tat = txt
|
||||
TAT = 1
|
||||
|
||||
if TTT == 0 and ttt:
|
||||
print(f' _("{ttt}"),')
|
||||
ttt = ''
|
||||
|
||||
if TAT == 0 and tat:
|
||||
print(f' _("{tat}"),')
|
||||
tat = ''
|
||||
|
||||
# bindings.cfg
|
||||
TDT = 0
|
||||
|
||||
if line.startswith('Tooltip'):
|
||||
line = line.strip()
|
||||
tok = line.split(' ', 1)
|
||||
if tdt:
|
||||
tdt += '\\n' + tok[1]
|
||||
else:
|
||||
tdt = tok[1]
|
||||
TDT = 1
|
||||
|
||||
if TDT == 0 and tdt:
|
||||
print(f' _("{tdt}"),')
|
||||
tdt = ''
|
||||
|
||||
# menus.cfg (obsolete)
|
||||
if line.find('ADD_MENU_TITLE') >= 0:
|
||||
txt = quote1(line)
|
||||
print(f' _("{txt}"),')
|
||||
elif line.find('ADD_MENU_TEXT_ITEM') >= 0 or \
|
||||
line.find('ADD_MENU_SUBMENU_TEXT_ITEM') >= 0:
|
||||
txt = quote1(line)
|
||||
print(f' _("{txt}"),')
|
||||
|
||||
|
||||
def do_line_menu(line):
|
||||
# *.menu
|
||||
if line.startswith('"'):
|
||||
txt = quote1(line)
|
||||
print(f' _("{txt}"),')
|
||||
|
||||
|
||||
# From e_gen_menu
|
||||
sl = [
|
||||
'User Menus',
|
||||
'User Application List',
|
||||
'Applications',
|
||||
'Epplets',
|
||||
'Restart',
|
||||
'Log Out',
|
||||
]
|
||||
|
||||
#
|
||||
# Start
|
||||
#
|
||||
print('#define _(x) x\n')
|
||||
print('const char *txt[] = {')
|
||||
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
print(f'/* {arg} */')
|
||||
f = open(arg, 'r')
|
||||
if arg.endswith('cfg'):
|
||||
for line in f:
|
||||
do_line_cfg(line)
|
||||
elif arg.endswith('menu'):
|
||||
for line in f:
|
||||
do_line_menu(line)
|
||||
f.close()
|
||||
|
||||
# Other strings.
|
||||
print('')
|
||||
for str in sl:
|
||||
print(f' _("{str}"),')
|
||||
|
||||
print('};')
|
Loading…
Reference in New Issue