znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
333 stars 82 forks source link

Add new feature to Translate(): Replace/Translate parameters #494

Open reneeb opened 9 months ago

reneeb commented 9 months ago

Proposed change

E.g. in ticket history german speaking users can see the entry 'Status geändert von "new" auf "open".', so the states aren't translated. This new feature for Translate() allows to define a subroutine where those parameters (e.g. 'new' and 'open') can be translated or replaced. This is fully backwards-compatible.

To use this feature, one has to pass an array ref in the translation definition. The first value has to be the translation string and the second one is a subroutine reference:

package Kernel::Language::de_Parameters;

use strict;
use warnings;

use utf8;

sub Data {
    my  = shift;

    ->{Translation}->{'Changed state from "%s" to "%s".'} = [
        'Status geändert von "%s" auf "%s".',
        \&TranslateStates,
    ];

    return 1;
}

sub TranslateStates {
    my  = ::OM->Get('Kernel::Language');

    reneeb = ->Translate( reneeb ) for @_;

    return @_;
}

1;

This shows for the above mentioned string Status geändert von "neu" auf "offen".'. So it's more consistent as the same values are shown to the Agent in all places.

image

Breaking change

Additional information

Checklist