X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Flocales.pl;h=8faea2148592301b4c35ed7630455d0750d9723a;hb=ed83f90c4d4cd38c50a563c4f7d7075d0254b045;hp=a83ff9fe610cfea284d9f76dabaa93b7fec356c2;hpb=4247547d2a925ddad7006cae89e5f9f1fda7d469;p=kivitendo-erp.git diff --git a/scripts/locales.pl b/scripts/locales.pl index a83ff9fe6..8faea2148 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -10,8 +10,10 @@ use utf8; use strict; BEGIN { - unshift(@INC, 'modules/override'); # Use our own versions of various modules (e.g. YAML). - push (@INC, 'modules/fallback'); # Only use our own versions of modules if there's no system version. + use FindBin; + + unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). + push (@INC, $FindBin::Bin . '/..'); } use Carp; @@ -25,9 +27,9 @@ use IO::Dir; 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; +use SL::System::Process; +use SL::YAML; $OUTPUT_AUTOFLUSH = 1; @@ -44,7 +46,7 @@ my $basedir = "../.."; my $locales_dir = "."; my $bindir = "$basedir/bin/mozilla"; my @progdirs = ( "$basedir/SL" ); -my @menufiles = <"${basedir}/menus/*/*">; +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; @@ -53,7 +55,7 @@ our $missing = {}; our @lost = (); my %ignore_unused_templates = ( - map { $_ => 1 } qw(ct/testpage.html generic/autocomplete.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js task_server/failure_notification_email.txt + map { $_ => 1 } qw(ct/testpage.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js task_server/failure_notification_email.txt failed_background_jobs_report/email.txt) ); @@ -112,6 +114,18 @@ foreach my $sub_dir ("Pg-upgrade2", "Pg-upgrade2-auth") { if (-f "$locales_dir/all") { require "$locales_dir/all"; } +# load custom translation (more_texts) +for my $file (glob("${locales_dir}/more/*")) { + if (open my $in, "<", "$file") { + local $/ = undef; + my $code = <$in>; + eval($code); + close($in); + $self->{more_texts_temp}{$_} = $self->{more_texts}{$_} for keys %{ $self->{more_texts} }; + } +} +$self->{more_texts} = delete $self->{more_texts_temp}; + if (-f "$locales_dir/missing") { require "$locales_dir/missing" ; unlink "$locales_dir/missing"; @@ -164,7 +178,8 @@ close($js_file); # calc and generate missing -my @new_missing = grep { !$self->{texts}{$_} } sort keys %alllocales; +# don't add missing ones if we have a translation in more_texts +my @new_missing = grep { !$self->{more_texts}{$_} && !$self->{texts}{$_} } sort keys %alllocales; if (@new_missing) { if ($opt_c) { @@ -517,7 +532,7 @@ sub scanfile { sub scanmenu { my $file = shift; - my $menu = YAML::LoadFile($file); + my $menu = SL::YAML::LoadFile($file); for my $node (@$menu) { # possible for override files @@ -533,7 +548,7 @@ 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; - my $dbu = SL::DBUpgrade2->new(auth => $auth, path => '../../sql/Pg-upgrade2-auth'); + my $dbu = SL::DBUpgrade2->new(auth => $auth, path => SL::System::Process->exe_dir . '/sql/Pg-upgrade2-auth'); for my $upgrade ($dbu->sort_dbupdate_controls) { for my $string (@{ $upgrade->{locales} || [] }) { @@ -615,7 +630,7 @@ sub scanhtmlfile { } while ($line =~ m/\[\% # Template-Start-Tag - [\-~#]? # Whitespace-Unterdrückung + [\-~#]* # Whitespace-Unterdrückung \s* # Optional beliebig viele Whitespace (?: # Die erkannten Template-Direktiven PROCESS