Custom field translation in RT 5.0.2

Hello RT community,

I have created some custom fields (First name, Last name, Gender and Entry date) and assigned them to a queue. These custom fields are grouped together in a section called Personal information via the CustomFieldGroupings config in RT_SiteConfig.pm.

See CustomFieldGroupings setting in RT_SiteConfig.pm
...
Set(%CustomFieldGroupings,
    'RT::Ticket' => [
        'Personal information' => ['First name', 'Last name', 'Gender', 'Entry date'],
    ],
);
...

Now I want to translate these custom fields in a differnent language (in my case in German).

So I’ve created a new po-file de.po in /opt/rt5/local/po/ with the following content:

msgid ""
msgstr ""

"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

# Custom field translations

# GROUP: Personal information
msgid "Personal information"
msgstr "Persönliche Daten"

# First name
msgid "First name"
msgstr "Vorname"

# Last name
msgid "Last name"
msgstr "Nachname"

# Gender
msgid "Gender"
msgstr "Geschlecht"

# Entry date
msgid "Entry date"
msgstr "Eintrittsdatum"

After clearing the Mason cache (sudo rm -rf /opt/rt5/var/mason_data/obj) and restarting the webserver (sudo service apache2 restart), it seems that only the group name has been translated but not the custom fields itself.

Can someone please help me, what I’m doing wrong or point me to the right direction?

If you need any further information, please let me know.

Thanks in advance.

Ronny


Systeminformation
RT Version 5.0.2
RT Extensions RT::Extension::ArticleTemplates
RT::Extension::ConditionalCustomFields
OS Ubuntu 20.04 LTS
DB MySQL

I don’t think names are translated since they are nouns, you would have to customize the code that shows the labels for the custom fields, like in /Elements/ShowCustomFields there is this code:

<div class="label col-<% $LabelCols %>"><% $CustomField->Name %>:

You could wrap the custom field name in loc()

Hi knation,

thanks for your quick reply.

As you suggested, I have copied the ShowCustomFields from share/html/Elements/ to local/html/Elements/ and changed the following line from

<div class="label col-<% $LabelCols %>"><% $CustomField->Name %>:

to

<div class="label col-<% $LabelCols %>"><% loc($CustomField->Name) %>:

But after clearing the Mason cache and restarting the webserver, the custom fields still remain “untranslated”. Is there maybe anything else I change somewhere?

I am glad for any help.

There is an edit component and a display component, so if you’re on the edit page or using inline edit you will also want to change share/html/Elements/EditCustomFields

There was my mistake in reasoning. :man_facepalming:

After I adjusted the code also for EditCustomFields, it now works like a charm and as aspected.

Thanks for your quick and straightforward help.

1 Like