Realizing i18n Internationalization with Connect in Spring Boot

Hi Community,

Internationalization for Confluence Apps is an issue we are struggling to realize using the atlassian-connect-spring-boot dependency. Everything is fairly well documented here concerning the app descriptor.
So we are adding

"translations": {
    "paths": {
        "fr-FR": "/i18n/fr_FR.json"
    }
}

to the atlassian-connect.json. In Internationalization for Connect apps it is described to add an i18n Property bean but the link is dead.
Our question is, whether there is a way (build into the Spring Boot Atlassian Connect Dependency) to expose the i18n JSON files or point the application to the file path. The current path is i.e. /ressources/i18n/de_DE.json. This file needs to be delivered during installation just as the atlassian-connect.json does. Meaning without any authorization kicking in.
Thank you all in advance :slight_smile:

Hi @HenryBurkhardt,

per the library README, you can use:

  • the @IgnoreJwt annotation - probably not appropriate here if you are serving static files.
  • the configuration property atlassian.connect.require-auth-exclude-paths.
1 Like

Simply serving up the entire translation file can result in installation errors that only show a 500 error to the user. This is because there is a limit to the size of the translation files served during the installation phase of the app.

For this I implemented a custom endpoint, that ignores the JWT, within the app (spring boot as well) that will only serve the i18n key value pairs used in the descriptor. This way the size limit of the translation files should not be hit.

I use this code snippet find all the i18n key referenced within the descriptor.

ObjectNode descriptor = (ObjectNode) objectMapper.readTree(rawDescriptor);

List<JsonNode> i18n = descriptor.findParents("i18n", null);

i18nKeys = i18n.stream()
   .filter(ObjectNode.class::isInstance)
   .map(ObjectNode.class::cast)
   .map(node -> node.get("i18n"))
   .map(JsonNode::asText)
   .collect(Collectors.toSet());

Then in your I18n endpoint you can use those i18nKeys to locate all the translations for what ever language.

2 Likes

Hi @epehrson and @markrekveld, thank you for these valuable answers. I will experiment with both a little :slight_smile: