404 error on i18n files

internationalization
i18n-404

#1

Hi all

I am going through the CLoud plugin tutorials. I am currently trying to add internationalization as described here:
https://developer.atlassian.com/cloud/confluence/internationalization/

I am using the Hello World example and created a folder “i18n”. In there I placed two files

  • de-DE.json
  • en-US.json

Both, have the same conent except of the language strings:

{
   "bg-color-macro.name": "Color",
   "bg-color-macro.desc": "Allow users to add a background colour around selected content.",
   "bg-color-macro.param.color.label": "Color",
   "bg-color-macro.param.color.desc": "Enter the color in HEX",
   "bg-color-macro.param.style.label": "CSS Styles",
   "bg-color-macro.param.style.desc": "Add more CSS styles here"
}

In atlassian-connect.json I added:

   "translations": {
      "paths": {
         "de-DE": "/i18n/de-DE.json",
         "en-US": "/i18n/en-US.json"
      }
   },

When running “npm start” I get the following error:

GET /i18n/en-US.json 404 2.461 ms - 154
GET /i18n/de-DE.json 404 1.168 ms - 154
Registered with host at https://johndoe-dev.atlassian.net/wiki
Add-on is disabled on https://johndoe-dev.atlassian.net/wiki. Enable manually via upm

What am I missing? Why the 404 even though the files exist?

Thanks and best regards,
George


#2

Hi all
I was able to solve this by moving the “i18n” folder into the “public” directory of the demo code and then referring to them in atlassian-connect.json like this:

   "translations": {
      "paths": {
         "de-DE": "i18n/de-DE.json",
         "en-US": "i18n/en-US.json"
      }
   },

Hope that helps others running into this problem as well.

Best regards,
George


#3

hi George !, Can I get your demo code ? I’m new for jira cloud and I need to support i18n for my add-on. I’ve read tutorial about i18n for jira cloud . But I don’t know where I can put this “translations” script and I don’t know how to use i18n key in file .jsx. Please help me ! Thank you so much !!!


#4

Hi Hyun
I don’t have that code anymore. The structure was this.
The translations declaration as shown in my previous post is in atlassian-connect.json in the root directory of my plugin.
The actual language files reside in the ia8n folder inside the public folder. It looked like this:

myplugin/public/i18n/de-DE.json
myplugin/public/i18n/de-DE.json
myplugin/atlassian-connect.json

Best regards,
George