Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

reneeb
Copy link
Collaborator

@reneeb reneeb commented Sep 13, 2023

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

  • '1 - 🚀 feature' - New feature (which adds functionality to an existing integration)

Breaking change

Additional information

Checklist

  • The code change is tested and works locally.(❗)
  • There is no commented out code in this PR.(❕)
  • You improved or added new unit tests.(❕)
  • Local ZnunyCodePolicy passed.(❕)
  • Local UnitTests / Selenium passed.(❕)
  • GitHub workflow CI (UnitTests / Selenium) passed.(❗)

…slation string

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.
@dignin dignin added 1 - 🚀 feature New feature or request 4 - verified This issue or pull request was verified. 1 - 💎 code quality Code quality improvements to existing code or addition of unit tests. labels Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - 💎 code quality Code quality improvements to existing code or addition of unit tests. 1 - 🚀 feature New feature or request 4 - verified This issue or pull request was verified.
Development

Successfully merging this pull request may close these issues.

4 participants