Adding custom metadata - translations

Hello!

My colleague @robert.paulsen and I are in the process of adding our own metadata fields, from the ruleset to the viewer. We have succeeded in getting the custom metadata field to show up in the viewer:

But there is something amiss with the translation. We have copied the messages_en.properties file to our /opt/digiverso/viewer/config folder and configured it thus:

image

However, it doesn’t work as demonstrated above. Does anybody know where we are stepping wrong here?

1 „Gefällt mir“

Hi @ahl.nilsen + @robert.paulsen

it’s great to read that you are already this far! Great progress and great success!! :slight_smile:

You don’t need to copy the entire messages file, only add the desired KEY=VALUE entries to the local one. Filename, folder and the format look good for me.

Have you tried restarting the tomcat process? If the file was not there during startup it might be, that the Goobi viewer does not recognize it. If you monitor the viewer.log file and you change something in the local message file you should see an entry like this:

DEBUG 2021-03-02 07:08:25.707 [Thread-6] io.goobi.viewer.messages.ViewerResourceBundle$1.run(ViewerResourceBundle.java:124)
        File 'messages_en.properties' (language: en) has been modified, triggering bundle reload...

Best wishes,

Jan :slight_smile:

1 „Gefällt mir“

Hi there,
could it be that you are editing the “wrong” messages file? Look here:

Maybe you must edit the messages-file in the viewer-core-XX.jar ?

The change you mentioned above makes it easier to get the global message bundle. You don’t need to extract it from the jar file anymore. Starting from January this year you can find them unpacked in the filesystem (again).

Editing the global message files is always a bad idea, because they are overwritten each time you install an update… :wink:

So it depends on the version @ahl.nilsen uses?

No. The mechanism with the local messages files was always the same.

The difference we have since January is, that if you see for example a string in the UI that is translated via the messages, let’s say “Reading lists”, and you would like to rename it to let’s say “Favorites”, and you are wondering now what message key to use, you had to extract the global message file from the following file:

/var/lib/tomcat9/webapps/viewer/WEB-INF/lib/viewer-core-XYZ.jar

Another solution was to look at Github. Until the end of the year they were here:

Starting from January you can simply open it on the same server in the filesystem at this location:

/var/lib/tomcat9/webapps/viewer/WEB-INF/classes/messages_en.properties
1 „Gefällt mir“

Hi,

Thanks for you reply! We are trucking along, soon ready to set our ship into the choppy waters of production :slight_smile:

I do see the same message as you in the viewer.log, but as you will see we get another interesting error message (sorry for the formatting):

    DEBUG 2021-03-02 14:36:17.323 [Thread-6] io.goobi.viewer.messages.ViewerResourceBundle$1.run(ViewerResourceBundle.java:124)
 File 'messages_en.properties' (language: en) has been modified, triggering bundle reload...
DEBUG 2021-03-02 14:36:19.487 [ajp-nio-127.0.0.1-8009-exec-4] o.goobi.viewer.messages.ViewerResourceBundle.checkAndLoadResourceBundles(ViewerResourceBundle.java:199)
    Reloading local resource bundle for 'en'... WARN  2021-03-02 14:36:19.488 [ajp-nio-127.0.0.1-8009-exec-4] io.goobi.viewer.messages.ViewerResourceBundle.checkAndLoadResourceBundles(ViewerResourceBundle.java:206)
    Could not load local resource bundle.

Could it be that this has something to do with wrong permissions perhaps?

Best,
Ahl

Hi Ahl,

This might also mean that the messages.properties file has bad syntax. For example, all non-ASCII characters in message values must be unicode escaped (e.g. “ä” becomes “\u00e4”).

Best regards,
Andrey

2 „Gefällt mir“

Hi Andrey,

Thanks, but this is not it. We’ve reduced our custom messages file to one line (MD_MEDIAFORM=Media form) but it still doesn’t do the trick.

Best,
Robert

Hi Robert,

Then maybe it has indeed to do with permissions. Please check that /opt/digiverso/viewer/config/messages*.properties have the same permissions as config_viewer.xml in that same folder (assuming your local config works correctly right now).

Best regards,
Andrey

Hi Andrey!

The current owner of both /opt/digiverso/viewer/config/messages_en.properties and /opt/digiverso/viewer/config/config_viewer.xml is tomcat:tomcat. Still no luck after a tomcat restart. Do you know if it is correct that the tomcat user + tomcat group should be the owner of these files?

Best,
Ahl

Hi Ahl,

As long as tomcat has permissions to read the file (and it’s the same tomcat user that is actually running the Tomcat instance in which your viewer is deployed), this should be correct. We usually leave the group on tomcat and set the user to whoever needs to edit the files at the moment.

What are the individual permission settingson the file?

Hi Andrey,

Ok, thanks for the clarification. These are the individual permissions on the file:

-rw-r--r--  1 tomcat tomcat   24 Mar  3 09:48 messages_en.properties

And for the config:
-rw-r--r-- 1 tomcat tomcat 20K Mar 2 11:00 config_viewer.xml

I’ve also tested that tomcat can read the files by doing a:

sudo -u tomcat tail messages_en.properties

which was successful.

Best,
Ahl

What about the permissions of the parent folder(s)?

The permissions for the /opt/digiverso/viewer folder:
drwxr-xr-x 36 tomcat tomcat 4.0K Feb 25 07:29 viewer

The permissions for the /opt/digiverso/viewer/config folder:
drwxr-xr-x 4 tomcat tomcat 4.0K Mar 3 11:58 config

Does this give you anything? I tried modifying the file @ /var/lib/tomcat9/webapps/viewer/WEB-INF/classes/messages_en.properties which worked fine. Can we rely on modifying this file if all else fails?

Just to make sure, you didn’t happen to change the path pointing to the local config folder in the default config file (/var/lib/tomcat/webapps/viewer/WEB-INF/classes/config_viewer.xml)?

It should say:
<config>
<configFolder>/opt/digiverso/viewer/config/</configFolder>
</config>

Best regards,
Andrey

Our config file points to the same folder as you wrote here. The only difference I see is that our config_viewer.xml lies within this path:

/var/lib/tomcat9/webapps/viewer/WEB-INF/classes/

While your path is without tomcat9, only tomcat. Could this be something?

best,
Ahl

Are you using an official “release” of the Goobi viewer or a snapshot? I could add more debugging output to the develop branch of the core.

Best regards,
Andrey

I followed the instructions at https://docs.goobi.io/goobi-viewer-en/devs-and-ops/3 so I guess I have an official release?

If we can rely on the default config file at /var/lib/tomcat9/webapps/viewer/WEB-INF/classes/config_viewer.xml we should be covered for the time being while we continue to debug why our local messages_en.properties cant be loaded.

Thanks for all the help, I appreciated it :slight_smile:

Best,
Ahl

@ahl.nilsen the global config_viewer.xml (/var/lib/tomcat9/webapps/viewer/WEB-INF/classes/config_viewer.xml) is overwritten each time you update the software. All modifications should be added to the local one (/opt/digiverso/viewer/config/config_viewer.xml)

:slight_smile: