Bug 25922: Add aria-label to the allowlist for translation
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 3 Jul 2020 13:07:25 +0000 (14:07 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Jul 2020 15:45:31 +0000 (17:45 +0200)
This patch adds aria-label to the allowlist for translations.

To test:
- Apply patches from here and bug 25244
- kshell
- cd misc/translator
- perl translate update de-DE
- Check for the aria-label in the diff
- Verify the strings appear in the po files now
- Translate them
- perl translate install de-DE
- Verify the translated strings appear in the template

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

misc/translator/tmpl_process3.pl
misc/translator/xgettext.pl

index 45a9b6e..9221430 100755 (executable)
@@ -64,7 +64,7 @@ sub text_replace_tag {
     # value [tag=input], meta
     my $tag = ($t =~ /^<(\S+)/s) ? lc($1) : undef;
     my $translated_p = 0;
-    for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder') {
+    for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder', 'aria-label') {
     if ($attr->{$a}) {
         next if $a eq 'label' && $tag ne 'optgroup';
         next if $a eq 'content' && $tag ne 'meta';
@@ -73,7 +73,7 @@ sub text_replace_tag {
         my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
         if ($val =~ /\S/s) {
             # for selected attributes replace '[%..%]' with '%s' and remember matches
-            if ( $a =~ /title|value|alt|content|placeholder/ ) {
+            if ( $a =~ /title|value|alt|content|placeholder|aria-label/ ) {
                 while ( $val =~ s/(\[\%.*?\%\])/\%s/ ) {
                     my $var = $1;
                     push @ttvar, $1;
@@ -82,7 +82,7 @@ sub text_replace_tag {
             # find translation for transformed attributes
             my $s = find_translation($val);
             # replace '%s' with original content (in order) on translated string, this is fragile!
-            if ( $a =~ /title|value|alt|content|placeholder/ and @ttvar ) {
+            if ( $a =~ /title|value|alt|content|placeholder|aria-label/ and @ttvar ) {
                 while ( @ttvar ) {
                     my $var = shift @ttvar;
                     $s =~ s/\%s/$var/;
index afac244..54360a1 100755 (executable)
@@ -117,7 +117,7 @@ sub text_extract {
             # value [tag=input], meta
             my $tag;
             $tag = lc($1) if $t =~ /^<(\S+)/s;
-            for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder') {
+            for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder', 'arial-label') {
                 if ($attr->{$a}) {
                     next if $a eq 'label' && $tag ne 'optgroup';
                     next if $a eq 'content' && $tag ne 'meta';
@@ -126,7 +126,7 @@ sub text_extract {
                     my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
                     $val = TmplTokenizer::trim($val);
                     # for selected attributes replace '[%..%]' with '%s' globally
-                    if ( $a =~ /title|value|alt|content|placeholder/ ) {
+                    if ( $a =~ /title|value|alt|content|placeholder|aria-label/ ) {
                         $val =~ s/\[\%.*?\%\]/\%s/g;
                     }
                     # save attribute text for translation