-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a translation api controller to the Delivery API #15132
Add a translation api controller to the Delivery API #15132
Conversation
that fetches the translations for the current request culture in a JSON format that can be used with https://www.i18next.com/
Hi there @ToxicKevinFerm, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Thank you @ToxicKevinFerm |
Hi! Yes, that's what I was thinking as well, it does look pretty clean right now. But I do think there is functionality missing that would fit very well there considering you might want to build a website with Next.js for example. The Delivery API does that very well today, but leaves something to be desired when you want dictionary values. It could just as well be a plugin extending the delivery api, but I thought I'd give it a shot here first =) |
Hi @ToxicKevinFerm, Thanks a lot for this ❤️ We're going to have a little pow-wow at HQ to figure out where the Dictionary places itself in respect to the Delivery API. Unfortunately we can't gather all relevant parties until early next week, so please have a little patience with us 😄 I'll get back to you here when I have something to share. |
Great! Thank you =) I'm open to changes for sure |
Hi @ToxicKevinFerm. Thank you again for contributing to Umbraco 💪 We agree that a Translation Delivery API would be a nice addition to the core. However, at this point there are a few things that prevent it. The main thing is that the To build a Translation API we first need to figure out a caching strategy for dictionary items. The next thing to consider is how to shape the API. Translations have historically been utilized in a number of different ways for any number of different purposes. When we add a core API, we need to make sure we've covered all (or most of) those use cases. So... we need to talk to people 😄 To start this whole process I have opened a discussion here: #15214 - feel free to chime in 👍 I'm going to close this PR now in favour of the discussion. I have cross-linked the discussion and the PR so we retain the history. At least for the time being, people will have to create their own Translation APIs to cater for their specific use cases.
|
Internationalization is important, so I would like a way to fetch Umbraco dictionary items. Preferably it would be using the request language, and return a json format similar to https://www.i18next.com/misc/json-format as a good standard in the field.
Prerequisites
Add a few translation items and test the API in
/umbraco/swagger/
Description
I added a
TranslationApiControllerBase
that creates a new route and section in the API Explorer "translation".Then I added a new controller endpoint
GetListTranslationApiController
with an optional startItem param that fetches dictionary values fromLocalizationService
and writes them to a json format.I'm not sure you need to be able to fetch a single item, but you can with
startItem
.The idea is to fetch your translations for a given language and cache it on the client side.
Here's where I'm a bit unsure of the Umbraco internals, do we need to index the dictionary items from
LocalizationService
? Do we need a cache or is the service fetching cached items already?This is a work in progress, and I'm not sure what your thoughts are on adding new controllers to the Delivery API, but I feel like it'd be a good addition. It's also my first time looking into the Umbraco Core, so I might be totally wrong on best practices and such.
I'm not sure what you want the Delivery API to be going forwards, but I would consider dictionary to be part of the content.