]> source.dussan.org Git - nextcloud-server.git/commitdiff
l10n.pl now generates js files as well
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 17 Oct 2014 12:17:39 +0000 (14:17 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Wed, 29 Oct 2014 09:09:12 +0000 (10:09 +0100)
l10n/init.sh [deleted file]
l10n/l10n.pl

diff --git a/l10n/init.sh b/l10n/init.sh
deleted file mode 100755 (executable)
index 98195bf..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-for resource in calendar contacts core files media gallery settings
-do
-tx set --auto-local -r owncloud.$resource "<lang>/$resource.po" --source-lang en --source-file templates/$resource.pot --execute
-done
index 10df5f8f8030bfd7b69e96b0d47a0cff162bf200..8b12f1abaedac7dd1e666d2490b0baf85a52d147 100644 (file)
@@ -142,6 +142,7 @@ elsif( $task eq 'write' ){
                        my $array = Locale::PO->load_file_asarray( $input );
                        # Create array
                        my @strings = ();
+                       my @js_strings = ();
                        my $plurals;
 
                        foreach my $string ( @{$array} ){
@@ -160,11 +161,13 @@ elsif( $task eq 'write' ){
                                        }
 
                                        push( @strings, "\"$identifier\" => array(".join(",", @variants).")");
+                                       push( @js_strings, "\"$identifier\" : [".join(",", @variants)."]");
                                }
                                else{
                                        # singular translations
                                        next if $string->msgstr() eq '""';
                                        push( @strings, $string->msgid()." => ".$string->msgstr());
+                                       push( @js_strings, $string->msgid()." : ".$string->msgstr());
                                }
                        }
                        next if $#strings == -1; # Skip empty files
@@ -179,6 +182,13 @@ elsif( $task eq 'write' ){
                        print OUT join( ",\n", @strings );
                        print OUT "\n);\n\$PLURAL_FORMS = \"$plurals\";\n";
                        close( OUT );
+
+                       open( OUT, ">$language.js" );
+                       print OUT "OC.L10N.register(\n    \"$app\",\n    {\n    ";
+                       print OUT join( ",\n    ", @js_strings );
+                       print OUT "\n},\n\"$plurals\");\n";
+                       close( OUT );
+
                }
                chdir( $whereami );
        }