JSON editor for labels

Hi all,
I just landed on Contentful and I was wondering whether it was possible to generate a custom JSON response, without having to manually paste it.
In particular, I want to generate a JSON of this type (for Angular’s ngx-translate, labels to be used in an app):
{
“HI”:“Hi there”,
“BYE”:“Bye!”
}
which, in Italian translation. would become

{
“HI”:“Ciao!”,
“BYE”:“Ciao!”
}

I found Repeater app, which gives me a friendly UI (though not keeping the keys among the languages), but it returns a REDUNDANT

“label”: [
{
“id”: “12345”,
“key”: “HI”,
“value”: “Hi there”
},
{
“id”: “54321”,
“key”: “BYE”,
“value”: “Bye!”
}
]

I would like to get my desired format, not needing editors to paste an externally-generated one.
Is it feasible with Contentful (and any plugin)?
Thanks in advance!

Hi,

I am a fuctional analyst and have done some developing in the past.

What you aim to achieve, is to my knowledge, not possible without returning other redundant information.

In our Contentful projects at our company we always keep the translations in JSON files in the frontend code.

The alternative you found seems the closest you can get to the solution, to my knowledge.

Another possibility would be to create a content type with nothing but a single JSON field and request that. However, that is a worse solution than having a translation file imo.

In another project that we’re currently developing, we’re choosing to manage the translations again in a JSON file but manage the JSON file in Contentful itself.

Kind regards,
Ruben S.

1 Like

Hi @ruben.szeker , thanks for your answer.
My aim would be easing content editors’ difficulty in entering the data, in particular when managinr more than a market/language, allowing them to be autonomous in updating the labels, with no need of developers and without forcing them to learn and use JSON format (and I’m not pointing out that a wrong quotes may break it - whoops, wondering whether Repeater supports it), possibly also including rich text editors.
I’ll go on with Repeater, but I’d love a “cleaner” solution available in Contentful for the future :slight_smile:

Hi,

If the aim is to ease content editing then I see 2 possible solutions, with everything being as it is:

  1. Create a “label” content type with a translatable text field for managing the translations. Very simple to introduce, but might have too many singular API calls with a lot of redundant information.

  2. Create a “labels” content type with a JSON field that holds all the translations per language and create a UI extension to provide a clean UI. However, this is considerably more work but you’ll have less redundant data per API call.

However, I still think your best bet would be to have a third-party solution that might be out there because neither solution really solves your problem fully.

Kind regards,
Ruben S.