Bugzilla – Attachment 109297 Details for
Bug 25067
Move PO file manipulation code into gulp tasks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25067: Fix translation of system preferences files
Bug-25067-Fix-translation-of-system-preferences-fi.patch (text/plain), 4.40 KB, created by
Julian Maurice
on 2020-08-29 16:20:16 UTC
(
hide
)
Description:
Bug 25067: Fix translation of system preferences files
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2020-08-29 16:20:16 UTC
Size:
4.40 KB
patch
obsolete
>From 348caef43d21e78d19e7c168cf4d964c4a67b91f Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Sat, 29 Aug 2020 20:15:38 +0400 >Subject: [PATCH] Bug 25067: Fix translation of system preferences files > >A previous patch reverted the string extraction mechanism for .pref >files but did not update the 'install' part. >This patch does just that. >--- > misc/translator/LangInstaller.pm | 44 +++++++++++++++----------------- > 1 file changed, 20 insertions(+), 24 deletions(-) > >diff --git a/misc/translator/LangInstaller.pm b/misc/translator/LangInstaller.pm >index be51394452..5baddeeccc 100644 >--- a/misc/translator/LangInstaller.pm >+++ b/misc/translator/LangInstaller.pm >@@ -148,34 +148,33 @@ sub po_filename { > } > > sub get_trans_text { >- my ($self, $msgctxt, $msgid) = @_; >+ my ($self, $msgid, $default) = @_; > >- my $key = ($msgctxt // '') . ";$msgid"; >- >- my $po = $self->{po}->{$key}; >+ my $po = $self->{po}->{Locale::PO->quote($msgid)}; > if ($po) { > my $msgstr = Locale::PO->dequote($po->msgstr); >- >- return $msgstr || $msgid; >+ if ($msgstr and length($msgstr) > 0) { >+ return $msgstr; >+ } > } > >- return $msgid; >+ return $default; > } > > sub get_translated_tab_content { >- my ($self, $tab, $tab_content) = @_; >+ my ($self, $file, $tab_content) = @_; > > if ( ref($tab_content) eq 'ARRAY' ) { >- return $self->get_translated_prefs($tab, $tab_content); >+ return $self->get_translated_prefs($file, $tab_content); > } > > my $translated_tab_content = { > map { > my $section = $_; > my $sysprefs = $tab_content->{$section}; >- my $context = "$tab > $section"; >+ my $msgid = sprintf('%s %s', $file, $section); > >- $self->get_trans_text($tab, $section) => $self->get_translated_prefs($context, $sysprefs); >+ $self->get_trans_text($msgid, $section) => $self->get_translated_prefs($file, $sysprefs); > } keys %$tab_content > }; > >@@ -183,7 +182,7 @@ sub get_translated_tab_content { > } > > sub get_translated_prefs { >- my ($self, $context, $sysprefs) = @_; >+ my ($self, $file, $sysprefs) = @_; > > my $translated_prefs = [ > map { >@@ -192,7 +191,7 @@ sub get_translated_prefs { > > my $translated_syspref = [ > map { >- $self->get_translated_pref("$context > $pref_name", $_ ); >+ $self->get_translated_pref($file, $pref_name, $_); > } @$_ > ]; > >@@ -204,10 +203,12 @@ sub get_translated_prefs { > } > > sub get_translated_pref { >- my ($self, $context, $syspref) = @_; >+ my ($self, $file, $pref_name, $syspref) = @_; > > unless (ref($syspref)) { >- return $self->get_trans_text($context, $syspref // ''); >+ $syspref //= ''; >+ my $msgid = sprintf('%s#%s# %s', $file, $pref_name, $syspref); >+ return $self->get_trans_text($msgid, $syspref); > } > > my $translated_pref = { >@@ -219,7 +220,8 @@ sub get_translated_pref { > if (($key eq 'choices' || $key eq 'multiple') && ref($value) eq 'HASH') { > $translated_value = { > map { >- $_ => $self->get_trans_text($context, $value->{$_}) >+ my $msgid = sprintf('%s#%s# %s', $file, $pref_name, $value->{$_}); >+ $_ => $self->get_trans_text($msgid, $value->{$_}) > } keys %$value > } > } >@@ -239,13 +241,7 @@ sub install_prefs { > exit; > } > >- my @po_entries = @{ Locale::PO->load_file_asarray($self->po_filename("-pref.po"), 'utf8') }; >- $self->{po} = { map { >- my $msgctxt = $_->msgctxt ? Locale::PO->dequote($_->msgctxt) : ''; >- my $msgid = Locale::PO->dequote($_->msgid); >- >- "$msgctxt;$msgid" => $_; >- } @po_entries }; >+ $self->{po} = Locale::PO->load_file_ashash($self->po_filename("-pref.po"), 'utf8'); > > for my $file ( @{$self->{pref_files}} ) { > my $pref = LoadFile( $self->{path_pref_en} . "/$file" ); >@@ -255,7 +251,7 @@ sub install_prefs { > my $tab = $_; > my $tab_content = $pref->{$tab}; > >- $self->get_trans_text(undef, $tab) => $self->get_translated_tab_content($tab, $tab_content); >+ $self->get_trans_text($file, $tab) => $self->get_translated_tab_content($file, $tab_content); > } keys %$pref > }; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25067
:
102432
|
103383
|
103403
|
103404
|
103440
|
103557
|
103558
|
103562
|
103563
|
103564
|
103565
|
103566
|
106503
|
106504
|
106505
|
106506
|
106507
|
106807
|
109272
|
109273
|
109274
|
109275
|
109276
|
109277
|
109295
|
109296
|
109297
|
110011
|
110012
|
110013
|
110014
|
110015
|
110016
|
110017
|
110018
|
110019
|
110776
|
111642
|
111643
|
113252
|
113255
|
113258