Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision af853490

Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt

  • ID af85349024c0d1fc6db899cd84708c7fb6dfb7f4
  • Vorgänger bdff2b07
  • Nachfolger 32d33e11

Verwalten von Einheitennamen für jede angelegte Sprache. Beim Druck werden die Einheitennamen durch diejenigen ersetzt, die für die ausgewählte Ausgabesprache gespeichert sind.

Unterschiede anzeigen:

bin/mozilla/am.pl
3531 3531
  AM->units_in_use(\%myconfig, $form, $units);
3532 3532
  map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
3533 3533

  
3534
  @languages = AM->language(\%myconfig, $form, 1);
3535

  
3534 3536
  @unit_list = ();
3535 3537
  foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
3536 3538
    map({ push(@unit_list, $units->{$_}); }
3537 3539
        sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
3538 3540
             grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
3539 3541
  }
3540
  map({ $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"}); } @unit_list);
3542
  my $i = 1;
3543
  foreach (@unit_list) {
3544
    $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
3545
    $_->{"UNITLANGUAGES"} = [];
3546
    foreach my $lang (@languages) {
3547
      push(@{ $_->{"UNITLANGUAGES"} },
3548
           { "idx" => $i,
3549
             "unit" => $_->{"name"},
3550
             "language_id" => $lang->{"id"},
3551
             "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
3552
             "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
3553
           });
3554
    }
3555
    $i++;
3556
  }
3541 3557

  
3542 3558
  $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3543 3559
  $ddbox = AM->unit_select_data($units, undef, 1);
3544 3560

  
3545 3561
  $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
3546 3562
  $form->header();
3547
  print($form->parse_html_template("am/edit_units", { "UNITS" => \@unit_list, "NEW_BASE_UNIT_DDBOX" => $ddbox }));
3563
  print($form->parse_html_template("am/edit_units",
3564
                                   { "UNITS" => \@unit_list,
3565
                                     "NEW_BASE_UNIT_DDBOX" => $ddbox,
3566
                                     "LANGUAGES" => \@languages }));
3548 3567

  
3549 3568
  $lxdebug->leave_sub();
3550 3569
}
......
3566 3585
    $base_unit = $form->{"new_base_unit"};
3567 3586
  }
3568 3587

  
3569
  AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"});
3588
  my @languages;
3589
  foreach my $lang (AM->language(\%myconfig, $form, 1)) {
3590
    next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
3591
    push(@languages, { "id" => $lang->{"id"},
3592
                       "localized" => $form->{"new_localized_$lang->{id}"},
3593
                       "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
3594
         });
3595
  }
3596

  
3597
  AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
3570 3598

  
3571 3599
  $form->{"saved_message"} = $locale->text("The unit has been saved.");
3572 3600

  
......
3575 3603
  $lxdebug->leave_sub();
3576 3604
}
3577 3605

  
3606
sub set_unit_languages {
3607
  $lxdebug->enter_sub();
3608

  
3609
  my ($unit, $languages, $idx) = @_;
3610

  
3611
  $unit->{"LANGUAGES"} = [];
3612

  
3613
  foreach my $lang (@{$languages}) {
3614
    push(@{ $unit->{"LANGUAGES"} },
3615
         { "id" => $lang->{"id"},
3616
           "localized" => $form->{"localized_${idx}_$lang->{id}"},
3617
           "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
3618
         });
3619
  }
3620

  
3621
  $lxdebug->leave_sub();
3622
}
3623

  
3578 3624
sub save_unit {
3579 3625
  $lxdebug->enter_sub();
3580 3626

  
3581 3627
  $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3582 3628
  AM->units_in_use(\%myconfig, $form, $old_units);
3583 3629

  
3630
  @languages = AM->language(\%myconfig, $form, 1);
3631

  
3584 3632
  $new_units = {};
3585 3633
  @delete_units = ();
3586 3634
  foreach $i (1..($form->{"rowcount"} * 1)) {
......
3592 3640
    if ($form->{"unchangeable_$i"}) {
3593 3641
      $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
3594 3642
      $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
3643
      set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3595 3644
      next;
3596 3645
    }
3597 3646

  
......
3610 3659
    my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
3611 3660
    $new_units->{$form->{"name_$i"}} = \%h;
3612 3661
    $new_units->{$form->{"name_$i"}}->{"row"} = $i;
3662
    set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3613 3663
  }
3614 3664

  
3615 3665
  foreach $unit (values(%{$new_units})) {

Auch abrufbar als: Unified diff