cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend nuxeo.war/ui/i18n/messages.json?

Mike_Kaganski
Confirmed Champ
Confirmed Champ

nuxeo-wopi addon does not declare any package dependencies. However, it obviously depends on nuxeo-web-ui, since the latter includes the strings used for tooltips: wopiLink.* in i18n/messages.json, that ends up in nuxeo.war/ui. These tooltips are generated also in that package: see _wopiTooltip.

This raises the question, when I want to prepare a simple addon atop of the nuxeo-wopi (so my addon depends on it), how do I provide more strings to the nuxeo.war/ui/i18n/messages.json? My package does not include any jar packages, and only adds some icons to ${env.home}/nuxeo.war/ui/images, and a config to ${env.config}, using copy scripting command.

But there seems to be no scripting command to extend existing json files; adding another json file to that directory is ignored by nuxeo; and manually editing the json gets overwritten on server restart.

What is the correct way to add some strings to nuxeo.war/ui/i18n/messages.json when installing a simple addon?

1 ACCEPTED ANSWER

Mike_Kaganski
Confirmed Champ
Confirmed Champ

I solved this using following method:

  1. I put my strings in web/nuxeo.war/ui/i18n/messages.json of the jar bundle
  2. I use this deployment-fragment.xml in OSGI-INF of the jar:
<?xml version="1.0"?>
<fragment version="1">
  <require>org.nuxeo.web.ui</require>
  <install>
    <delete path="${bundle.fileName}.tmp"/>
    <unzip from="${bundle.fileName}" to="${bundle.fileName}.tmp" prefix="web">
      <include>web/nuxeo.war/**</include>
    </unzip>
    <append from="${bundle.fileName}.tmp/nuxeo.war/ui/i18n/messages.json" to="nuxeo.war/ui/i18n/messages.json"/>
    <delete path="${bundle.fileName}.tmp"/>
  </install>
</fragment>
  1. The jar bundle is installed using the update scripting command in install.xml of the addon package:
<update file="${package.root}/install/bundles" todir="${env.bundles}" />

When I have localized strings, I will add relevant messages-lang.json to web/nuxeo.war/ui/i18n/, and append more append commands to the deployment-fragment.xml.

View answer in original post

3 REPLIES 3

Mike_Kaganski
Confirmed Champ
Confirmed Champ

The i18n in nuxeo-web-ui is implemented in [nuxeo-elements/ui/nuxeo-i18n-behavior.js](https

Mike_Kaganski
Confirmed Champ
Confirmed Champ

Seems deployment-fragment.xml's [append](https

Mike_Kaganski
Confirmed Champ
Confirmed Champ

I solved this using following method:

  1. I put my strings in web/nuxeo.war/ui/i18n/messages.json of the jar bundle
  2. I use this deployment-fragment.xml in OSGI-INF of the jar:
<?xml version="1.0"?>
<fragment version="1">
  <require>org.nuxeo.web.ui</require>
  <install>
    <delete path="${bundle.fileName}.tmp"/>
    <unzip from="${bundle.fileName}" to="${bundle.fileName}.tmp" prefix="web">
      <include>web/nuxeo.war/**</include>
    </unzip>
    <append from="${bundle.fileName}.tmp/nuxeo.war/ui/i18n/messages.json" to="nuxeo.war/ui/i18n/messages.json"/>
    <delete path="${bundle.fileName}.tmp"/>
  </install>
</fragment>
  1. The jar bundle is installed using the update scripting command in install.xml of the addon package:
<update file="${package.root}/install/bundles" todir="${env.bundles}" />

When I have localized strings, I will add relevant messages-lang.json to web/nuxeo.war/ui/i18n/, and append more append commands to the deployment-fragment.xml.