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.
my html file
< i t="[title]test-object.debug-var"></ i >
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?
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.
Let’s try to isolate it in a fresh new app than it’s going to be shareable and we can take a look
It looks like your translation.json is wrongly formatted:
“debug-var”: “DEBUG”, <<<<==== this comma shouldn’t be here
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.