projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
epic-ts
[kivitendo-erp.git]
/
scripts
/
locales.pl
diff --git
a/scripts/locales.pl
b/scripts/locales.pl
index
b192714
..
2c31f87
100755
(executable)
--- a/
scripts/locales.pl
+++ b/
scripts/locales.pl
@@
-25,6
+25,9
@@
use IO::Dir;
use List::MoreUtils qw(apply);
use List::Util qw(first);
use Pod::Usage;
use List::MoreUtils qw(apply);
use List::Util qw(first);
use Pod::Usage;
+use YAML ();
+use YAML::Loader (); # YAML tries to load Y:L at runtime, but can't find it after we chdir'ed
+use SL::DBUpgrade2;
$OUTPUT_AUTOFLUSH = 1;
$OUTPUT_AUTOFLUSH = 1;
@@
-41,7
+44,7
@@
my $basedir = "../..";
my $locales_dir = ".";
my $bindir = "$basedir/bin/mozilla";
my @progdirs = ( "$basedir/SL" );
my $locales_dir = ".";
my $bindir = "$basedir/bin/mozilla";
my @progdirs = ( "$basedir/SL" );
-my @menufiles =
<${basedir}/menus/*.ini>
;
+my @menufiles =
glob("${basedir}/menus/*/*")
;
my @javascript_dirs = ($basedir .'/js', $basedir .'/templates/webpages');
my $javascript_output_dir = $basedir .'/js';
my $submitsearch = qr/type\s*=\s*[\"\']?submit/i;
my @javascript_dirs = ($basedir .'/js', $basedir .'/templates/webpages');
my $javascript_output_dir = $basedir .'/js';
my $submitsearch = qr/type\s*=\s*[\"\']?submit/i;
@@
-98,13
+101,6
@@
push @progfiles, map { m:^(.+)/([^/]+)$:; [ $2, $1 ] } grep { /\.pm$/ } map { fi
# put customized files into @customfiles
my %dir_h;
# put customized files into @customfiles
my %dir_h;
-if ($opt_n) {
- @customfiles = ();
-} else {
- tie %dir_h, 'IO::Dir', $basedir;
- push @menufiles, map { "$basedir/$_" } grep { /.*_menu.ini$/ } keys %dir_h;
-}
-
my @dbplfiles;
foreach my $sub_dir ("Pg-upgrade2", "Pg-upgrade2-auth") {
my $dir = "$basedir/sql/$sub_dir";
my @dbplfiles;
foreach my $sub_dir ("Pg-upgrade2", "Pg-upgrade2-auth") {
my $dir = "$basedir/sql/$sub_dir";
@@
-130,6
+126,7
@@
my %old_texts = %{ $self->{texts} || {} };
handle_file(@{ $_ }) for @progfiles;
handle_file(@{ $_ }) for @dbplfiles;
scanmenu($_) for @menufiles;
handle_file(@{ $_ }) for @progfiles;
handle_file(@{ $_ }) for @dbplfiles;
scanmenu($_) for @menufiles;
+scandbupgrades();
for my $file_name (grep { /\.(?:js|html)$/i } map({find_files($_)} @javascript_dirs)) {
scan_javascript_file($file_name);
for my $file_name (grep { /\.(?:js|html)$/i } map({find_files($_)} @javascript_dirs)) {
scan_javascript_file($file_name);
@@
-520,24
+517,31
@@
sub scanfile {
sub scanmenu {
my $file = shift;
sub scanmenu {
my $file = shift;
- my $fh = new FileHandle;
- open $fh, '<:encoding(utf8)', $file or die "$! : $file";
+ my $menu = YAML::LoadFile($file);
- my @a = grep m/^\[/, <$fh>;
- close($fh);
+ for my $node (@$menu) {
+ # possible for override files
+ next unless exists $node->{name};
+
+ $locale{$node->{name}} = 1;
+ $alllocales{$node->{name}} = 1;
+ $cached{$file}{all}{$node->{name}} = 1;
+ }
+}
- # strip []
- grep { s/(\[|\])//g } @a;
+sub scandbupgrades {
+ # we only need to do this for auth atm, because only auth scripts can include new rights, which are translateable
+ my $auth = 1;
- foreach my $item (@a) {
- my @b = split /--/, $item;
-
foreach my $string (@b
) {
- chomp $string;
+ my $dbu = SL::DBUpgrade2->new(auth => $auth, path => '../../sql/Pg-upgrade2-auth');
+
+
for my $upgrade ($dbu->sort_dbupdate_controls
) {
+ for my $string (@{ $upgrade->{locales} || [] }) {
$locale{$string} = 1;
$alllocales{$string} = 1;
$locale{$string} = 1;
$alllocales{$string} = 1;
+ $cached{$upgrade->{tag}}{all}{$string} = 1;
}
}
}
}
-
}
sub unescape_template_string {
}
sub unescape_template_string {
@@
-611,7
+615,7
@@
sub scanhtmlfile {
}
while ($line =~ m/\[\% # Template-Start-Tag
}
while ($line =~ m/\[\% # Template-Start-Tag
- [\-~#]
?
# Whitespace-Unterdrückung
+ [\-~#]
*
# Whitespace-Unterdrückung
\s* # Optional beliebig viele Whitespace
(?: # Die erkannten Template-Direktiven
PROCESS
\s* # Optional beliebig viele Whitespace
(?: # Die erkannten Template-Direktiven
PROCESS
@@
-780,7
+784,7
@@
Be more verbose.
=head1 DESCRIPTION
=head1 DESCRIPTION
-This script collects strings from Perl files, the menu
.ini file
and
+This script collects strings from Perl files, the menu
files
and
HTML templates and puts them into the file "all" for translation.
=cut
HTML templates and puts them into the file "all" for translation.
=cut