3 use SL::GenericTranslations;
4 use SL::Locale::String qw(t8);
9 $main::lxdebug->enter_sub();
11 $main::auth->assert('config');
13 my $form = $main::form;
14 my $locale = $main::locale;
16 $form->get_lists('languages' => 'LANGUAGES');
18 my $translation_list = GenericTranslations->list();
19 my %translations = ();
21 my @types = qw(male female);
23 foreach my $translation (@{ $translation_list }) {
24 $translation->{language_id} ||= 'default';
25 $translations{$translation->{language_id} . '::' . $translation->{translation_type}} = $translation;
28 unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', };
30 foreach my $language (@{ $form->{LANGUAGES} }) {
31 foreach my $type (@types) {
32 $language->{$type} = { };
33 my $translation = $translations{"$language->{id}::greetings::${type}"} || { };
34 $language->{$type} = $translation->{translation};
38 setup_generictranslations_edit_greetings_action_bar();
40 $form->{title} = $locale->text('Edit greetings');
42 print $form->parse_html_template('generictranslations/edit_greetings');
44 $main::lxdebug->leave_sub();
48 $main::lxdebug->enter_sub();
50 $main::auth->assert('config');
52 my $form = $main::form;
53 my $locale = $main::locale;
55 $form->get_lists('languages' => 'LANGUAGES');
57 unshift @{ $form->{LANGUAGES} }, { };
59 my @types = qw(male female);
61 foreach my $language (@{ $form->{LANGUAGES} }) {
62 foreach my $type (@types) {
63 GenericTranslations->save('translation_type' => "greetings::${type}",
64 'translation_id' => undef,
65 'language_id' => $language->{id},
66 'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__${type}"},);
70 $form->{message} = $locale->text('The greetings have been saved.');
74 $main::lxdebug->leave_sub();
77 sub edit_sepa_strings {
78 $main::lxdebug->enter_sub();
80 $main::auth->assert('config');
82 my $form = $main::form;
83 my $locale = $main::locale;
85 $form->get_lists('languages' => 'LANGUAGES');
87 my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx');
88 my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list };
90 my $translation_list_vc = GenericTranslations->list(translation_type => 'sepa_remittance_vc_no_pfx');
91 my %translations_vc = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list_vc };
93 unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', };
95 foreach my $language (@{ $form->{LANGUAGES} }) {
96 $language->{translation} = $translations{$language->{id}};
97 $language->{translation_vc} = $translations_vc{$language->{id}};
100 setup_generictranslations_edit_sepa_strings_action_bar();
102 $form->{title} = $locale->text('Edit SEPA strings');
104 print $form->parse_html_template('generictranslations/edit_sepa_strings');
106 $main::lxdebug->leave_sub();
109 sub save_sepa_strings {
110 $main::lxdebug->enter_sub();
112 $main::auth->assert('config');
114 my $form = $main::form;
115 my $locale = $main::locale;
117 $form->get_lists('languages' => 'LANGUAGES');
119 unshift @{ $form->{LANGUAGES} }, { };
121 foreach my $language (@{ $form->{LANGUAGES} }) {
122 GenericTranslations->save('translation_type' => 'sepa_remittance_info_pfx',
123 'translation_id' => undef,
124 'language_id' => $language->{id},
125 'translation' => $form->{"translation__" . ($language->{id} || 'default')},);
126 GenericTranslations->save('translation_type' => 'sepa_remittance_vc_no_pfx',
127 'translation_id' => undef,
128 'language_id' => $language->{id},
129 'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__vc" },);
132 $form->{message} = $locale->text('The SEPA strings have been saved.');
136 $main::lxdebug->leave_sub();
139 sub setup_generictranslations_edit_greetings_action_bar {
142 for my $bar ($::request->layout->get('actionbar')) {
146 submit => [ '#form', { action => "save_greetings" } ],
147 accesskey => 'enter',
153 sub setup_generictranslations_edit_sepa_strings_action_bar {
156 for my $bar ($::request->layout->get('actionbar')) {
160 submit => [ '#form', { action => "save_sepa_strings" } ],
161 accesskey => 'enter',