Kernel::System::Translation

NAME

Kernel::System::Translation – Methods for managing Translations

MethodParamValidationSchema()

Returns parameter validation definitions.

AddTranslation()

Creates a new Translation.

    my $NewTranslation = $TranslationObject->AddTranslation(
        Language    => 'pt'       # required
        Text        => 'elephant' # required
        Translation => 'elefante' # required
        UserID      => 1          # required
    );

Returns

    undef - in case of any error
    $NewTranslation = {
        ID          => 12345, # ID of the new Translation
        StringID    => 45678,
        Language    => 'pt',
        Text        => 'elephant',
        TextHash    => 'f87ee5ffc8e4828e...',
        Translation => 'elefante',
        CreateTime  => '2024-04-19 14:19:06',
        CreateBy    => 1,
        ChangeTime  => '2024-04-19 14:19:06',
        ChangeBy    => 1,
    }

UpdateTranslation()

Updates an existing Translation.

    my $Result = $TranslationObject->UpdateTranslation(
        ID          => 12345      # required, ID of the Translation to be updated
        Translation => 'Elefante' # required, new value for the Translation
        UserID      => 2          # required, UserID taken for ChangeBy field
    );

Returns

    1 if update was successfull, undef otherwise

DeleteTranslation()

Deletes an existing Translation.

    my $Result = $TranslationObject->DeleteTranslation(
        ID => 12345 # required, ID of the Translation to be deleted
    );

Returns

    1 if delete was successfull, undef otherwise

GetTranslation()

Gets an existing Translation info by ID.

    my $Translation = $TranslationObject->GetTranslation(
        ID => 12345 # required, ID of the Translation to be read
    );

Returns

    undef - in case of any error or the ID does not exist
    $Translation = {
        ID          => 12345, # ID of the new Translation
        StringID    => 45678,
        Language    => 'pt',
        Text        => 'elephant',
        TextHash    => 'f87ee5ffc8e4828e...',
        Translation => 'Elefante',
        CreateTime  => '2024-04-19 14:19:06',
        CreateBy    => 1,
        ChangeTime  => '2024-04-19 14:29:06',
        ChangeBy    => 2,
    }

GetTranslationByTextAndLanguage()

Gets an existing Translation info by Text and Language.

    my $Translation = $TranslationObject->GetTranslationByTextAndLanguage(
        Text     => 'elephant', # required, Text of the Translation to be read
        Language => 'pt',       # required, Language of the Translation to be read
    );

Returns

    undef in case of error; {} if such translation does not exist
    $Translation = {
        ID          => 12345, # ID of the Translation
        StringID    => 45678,
        Language    => 'pt',
        Text        => 'elephant',
        TextHash    => 'f87ee5ffc8e4828e...',
        Translation => 'Elefante',
        CreateTime  => '2024-04-19 14:19:06',
        CreateBy    => 1,
        ChangeTime  => '2024-04-19 14:29:06',
        ChangeBy    => 2,
    }

GetTranslationByTextHashAndLanguage()

Gets an existing Translation info by TextHash and Language.

    my $Translation = $TranslationObject->GetTranslationByTextAndLanguage(
        TextHash => 'sha-hash', # required, TextHash of the Translation to be read
        Language => 'pt',       # required, Language of the Translation to be read
    );

Returns

    undef in case of error; {} if such translation does not exist
    $Translation = {
        ID          => 12345, # ID of the Translation
        StringID    => 45678,
        Language    => 'pt',
        Text        => 'elephant',
        TextHash    => 'f87ee5ffc8e4828e...',
        Translation => 'Elefante',
        CreateTime  => '2024-04-19 14:19:06',
        CreateBy    => 1,
        ChangeTime  => '2024-04-19 14:29:06',
        ChangeBy    => 2,
    }

ListLanguageTranslations()

Return list of translations for the language

    my $List = $TranslationObject->ListLanguageTranslations(
        Language => '...' # required
    );

Returns

    undef - in case of any error
    list  - [
        {
            ID          => '...',
            StringID    => '...',
            Text        => '...',
            TextHash    => '...',
            Translation => '...',
            CreateTime  => '...',
            CreateBy    => '...',
            ChangeTime  => '...',
            ChangeBy    => '...',
        },
        ...
    ]

GenerateTextHash()

Generates a sha256 hash of the text.

    my $Hash = $TranslationObject->GenerateTextHash( Text => '...' );

AddOrUpdateTranslation()

If a Translation already exists for the given Text/Language arguments it gets updated. Otherwise a new one is created. Returns 1 if all went ok, 0 otherwise.

ImportCSV()

Import translations in CSV format.

    my $Result = $TranslationObject->ImportCSV(
        # If is running as a console command or not.
        InConsole => '...', # optional (0|1), default '0'

        Text      => '...', # required
        UserID    => '...', # required
    );

Returns

    error           - { Success => 0 }
    success         - { Success => 1 }

    # When used in the context of console command.
    partial success - { Success => 1, WithErrors => 1 }

ExportCSV()

Export translations in CSV format.

    my $Result = $TranslationObject->ExportCSV(
        # If is running as a console command or not.
        InConsole => '...', # optional (0|1), default '0'

        Codes      => '...', # required
        All        => '...', # optional (0|1), default '0'
        Filename => '...', # required
    );

Returns

    error           - { Success => 0 }
    success         - { Success => 1 }

    # When used in the context of console command.
    partial success - { Success => 1, WithErrors => 1 }

PRIVATE METHODS

Scroll to Top