Revision 98e3e577
Von Geoffrey Richardson vor mehr als 15 Jahren hinzugefügt
bin/mozilla/generictranslations.pl | ||
---|---|---|
1 |
use SL::Auth; |
|
2 |
use SL::Form; |
|
3 |
use SL::GenericTranslations; |
|
4 |
|
|
5 |
sub edit_greetings { |
|
6 |
$lxdebug->enter_sub(); |
|
7 |
|
|
8 |
$auth->assert('config'); |
|
9 |
|
|
10 |
$form->get_lists('languages' => 'LANGUAGES'); |
|
11 |
|
|
12 |
my $translation_list = GenericTranslations->list(); |
|
13 |
my %translations = (); |
|
14 |
|
|
15 |
my @types = qw(male female); |
|
16 |
|
|
17 |
foreach my $translation (@{ $translation_list }) { |
|
18 |
$translation->{language_id} ||= 'default'; |
|
19 |
$translations{$translation->{language_id} . '::' . $translation->{translation_type}} = $translation; |
|
20 |
} |
|
21 |
|
|
22 |
unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', }; |
|
23 |
|
|
24 |
foreach my $language (@{ $form->{LANGUAGES} }) { |
|
25 |
foreach my $type (@types) { |
|
26 |
$language->{$type} = { }; |
|
27 |
my $translation = $translations{"$language->{id}::greetings::${type}"} || { }; |
|
28 |
$language->{$type} = $translation->{translation}; |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
$form->{title} = $locale->text('Edit greetings'); |
|
33 |
$form->header(); |
|
34 |
print $form->parse_html_template('generictranslations/edit_greetings'); |
|
35 |
|
|
36 |
$lxdebug->leave_sub(); |
|
37 |
} |
|
38 |
|
|
39 |
sub save_greetings { |
|
40 |
$lxdebug->enter_sub(); |
|
41 |
|
|
42 |
$auth->assert('config'); |
|
43 |
|
|
44 |
$form->get_lists('languages' => 'LANGUAGES'); |
|
45 |
|
|
46 |
unshift @{ $form->{LANGUAGES} }, { }; |
|
47 |
|
|
48 |
my @types = qw(male female); |
|
49 |
|
|
50 |
foreach my $language (@{ $form->{LANGUAGES} }) { |
|
51 |
foreach my $type (@types) { |
|
52 |
GenericTranslations->save('translation_type' => "greetings::${type}", |
|
53 |
'translation_id' => undef, |
|
54 |
'language_id' => $language->{id}, |
|
55 |
'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__${type}"},); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
$form->{message} = $locale->text('The greetings have been saved.'); |
|
60 |
|
|
61 |
edit_greetings(); |
|
62 |
|
|
63 |
$lxdebug->leave_sub(); |
|
64 |
} |
|
65 |
|
|
66 |
1; |
Auch abrufbar als: Unified diff
generictranslations.pl nachgereicht