The code you see here has portions that are omitted or changed since I am not allowed to spread the code of my company
I am trying to load the value of a certain key in my translation.json file but for whatever reason every new key I create is not accessible when using a t tag.
I have defined a test key, with a value of “DEBUG” but for some reason I cannot use it with my t tag, all the other keys are usable but not mine, is there something I am missing? I have three translation.json files for different languages, I have tried defining the same key in the other files with no success.
translation.json:
“test-object”: {
“debug-var”: “DEBUG”,
},
my html file
< i t="[title]test-object.debug-var"></ i >
1 Like
Not sure it’s related to this but perhaps assigning the key to the title of an italic tag isn’t the best choice. Have you tried replacing the content instead? Can you also recreate the same issue with a fresh new project?
2 Likes
I don’t think there is an issue with the italic tag or the content of the tag itself. When I use other keys that others have already defined then it works just fine but my key will not work for some weird reason.
1 Like
Let’s try to isolate it in a fresh new app than it’s going to be shareable and we can take a look
1 Like
It looks like your translation.json is wrongly formatted:
translation.json:
“test-object”: {
“debug-var”: “DEBUG”, <<<<==== this comma shouldn’t be here
},
3 Likes
On top of what has been discussed so far…
First ensure that the correct translation files are being provided to client. If you are using fetch it is easiest to verify by simply inspecting the network requests in browser’s dev tool. Regardless of that you can still use the Aurelia Inspector to verify the correctnessof the resource by looking at the i18next
property of the I18N
instance (I think you need to look at the i18next.resources
property for that).
If the translation resources are correctly loaded, give a try by removing the -
(hyphen) from the key name. For this, it is also a good idea to verify the separators used in your app.
I got some help from a coworker. They forgot to tell me that I need to do a hard refresh every time I update a translation, it’s working now.