Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 440ad8d3

Von Thomas Heck vor mehr als 11 Jahren hinzugefügt

  • ID 440ad8d3e9fada111bf174d11081c910c361acef
  • Vorgänger bc08036a
  • Nachfolger 3c416dd9

JS-Übersetzung immer in HEAD laden

Unterschiede anzeigen:

SL/Layout/None.pm
29 29
    js/jquery.js
30 30
    js/common.js
31 31
    js/namespace.js
32
    js/kivi.js
32 33
  ),
34
  'js/locale/'. $::myconfig{countrycode} .'.js',
33 35
  $self->SUPER::use_javascript(@_);
34 36
}
35 37

  
js/kivi.js
1 1
namespace("kivi", function(ns) {
2

  
3
  ns._localeLang = false;
4
  ns._locales = {};
2
  ns._locale = {};
5 3

  
6 4
  ns.t8 = function(text, params) {
7
    if( ns._localeLang ) {
8
      if( !ns._locales[ns._localeLang] ) {
9
        ns._locales[ns._localeLang] = {};
10

  
11
        jQuery.ajax({
12
          url: "js/locale/"+ ns._localeLang +".js",
13
          async: false,
14
          dataType: "json",
15
          success: function(res) {
16
            ns._locales[ns._localeLang] = res;
17
          },
18
        });
19
      }
20

  
21
      text = ns._locales[ns._localeLang][text] || text;
22
    }
5
    var text = ns._locale[text] || text;
23 6

  
24 7
    if( Object.prototype.toString.call( params ) === '[object Array]' ) {
25 8
      var len = params.length;
......
40 23
    return text;
41 24
  };
42 25

  
43
  ns.initLocale = function(localeLang) {
44
    ns._localeLang = localeLang;
26
  ns.setupLocale = function(locale) {
27
    ns._locale = locale;
45 28
  };
46

  
47 29
});
30

  
31
kivi = namespace('kivi');
js/locale/de.js
1
{
2
}
1
namespace("kivi").setupLocale({
2
});
scripts/locales.pl
143 143
);
144 144

  
145 145
open(my $js_file, '>:encoding(utf8)', $javascript_output_dir .'/locale/'. $locale .'.js') || die;
146
print $js_file '{';
146
print $js_file 'namespace("kivi").setupLocale({';
147 147
my $first_entry = 1;
148 148
for my $key (sort(keys(%jslocale))) {
149 149
  print $js_file ((!$first_entry ? ',' : '') ."\n". _double_quote($key) .':'. _double_quote($self->{texts}{$key}));
150 150
  $first_entry = 0;
151 151
}
152
print $js_file ("\n".'}'."\n");
152
print $js_file ("\n");
153
print $js_file ('});'."\n");
153 154
close($js_file);
154 155

  
155 156
  foreach my $text (keys %$missing) {
templates/webpages/layout/javascript_setup.js
1 1
[%- USE T8 %]
2 2
$(function() {
3 3
[% IF datefmt %]
4
  namespace("kivi").initLocale("[% MYCONFIG.countrycode | html %]");
5 4
  setupPoints('[% MYCONFIG.numberformat %]', '[% 'wrongformat' | $T8 %]');
6 5
  setupDateFormat('[% MYCONFIG.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]');
7 6

  

Auch abrufbar als: Unified diff