Pluralise translation shown as a JSON string
jamiejones93 opened this issue · comments
Describe the bug
When a translation has is_plural: true
, the translation will become a string of JSON
To Reproduce
Fetch a key that has pluralisation enabled
const keys = await lokaliseApi.keys.list({
...
})
console.log(keys.items[0].translation) // this becomes a string of JSON
Expected behavior
For the translation to be a parsed object
Your environment:
- Node version 14
CC @ycmjason
With the following code:
const keys = await lokaliseApi.keys.list({
project_id: "7011443960a248cd821a99.03389258",
include_translations: 1,
});
console.log(keys.items[0].translations);
I can see the following result:
{
translation_id: 656300673,
key_id: 91036314,
language_iso: 'en',
translation: '{"one":"1 error was found!","other":"[%i] errors were found!"}',
modified_by: 20181,
modified_at: '2021-05-17 10:48:54 (Etc/UTC)',
modified_at_timestamp: 1621248534,
is_reviewed: false,
reviewed_by: 0,
is_unverified: false,
is_fuzzy: false,
words: 7,
custom_translation_statuses: [],
task_id: null
}
Basically, an object is returned for a plural key. Is this what you were trying to achieve?.. I don't think that items[0]
has a translation
property. Also, to properly grab all translations for a key, one has to set include_translations
to 1
If that's not what you meant, could you please show an example of what is returned in your case?
@jamesjones93 Is this issue still relevant?
I'm going to close this issue for now but if you have further questions please don't hesitate to reopen it!
Hi @bodrovis sorry for the delay!
The issue was that translation: '{"one":"1 error was found!","other":"[%i] errors were found!"}',
comes back as a string - maybe it would make sense for this library to parse the result?
Hope this clarifies things
Oh okay, I'll see what can be done, thanks!