next-translate icon indicating copy to clipboard operation
next-translate copied to clipboard

Feature Request: API to replace translations on runtime

Open sapkra opened this issue 3 years ago • 1 comments

We are using a SaaS tool to manage our translations but if one translation has changed we want to call a webhook of next.js to invalidate the old translation and replace it with the new one.

It would be great to have a function to replace a translation:

function replaceTranslation(locale: string, namespace: string, newTranslation: string) {...}

replaceTranslation('en', 'common', 'This is the new translation.')

sapkra avatar May 23 '21 09:05 sapkra

@sapkra is something unfeasible because being able to overwrite the function loadLocaleFrom, the translations can be anywhere, in JSON or any format, inside the project, or in an external API... So reading the translations is feasible, but overwriting them is more complicated.

If you use the locals inside the project, you can overwrite them with fs and revalidate the pages that have getStaticProps.

aralroca avatar May 23 '21 10:05 aralroca