Home
Support Forums

Translate content via Functions

Hi,

still in development process but getting close to deploy our site to Netlify.

We have plans to write content in our sites main language (en-US), via Netlify CMS built with 11ty.

This content should then be translated into XY other languages via a third-party API.

After giving it some thoughts, I believe the best way to achieve this would be to run a scheduled Lambda Function with Netlify.

The function would then scan all/parts of the content directories to check which ones have a frontmatter key of translated: false, translate content and frontmatter and then save it and make a github commit.

The netlify CMS is configured to set the translated key to false whenever a post is created or updated, to ensure translations are always up to date.

Now in theory this all tracks I believe :slight_smile:

What about reality though?
Is what we’re planning possible or are any parts of the above not doable, or maybe require a different approach?

To begin with, a scheduled lama function is not yet possible unless you’re scheduling something to call the function.

Furthermore, this seems more practical to do with GitHub Actions than Netlify Functions. I’m not sure if it’s even possible to commit to a repo using Functions. It might be, but doesn’t seem practical enough to me because cloning a repo, finding the articles, translating them and committing them back doesn’t seem something that’s possible within 10 seconds.

However, configuring a GitHub action and using the third-party API might be a problem.

Hey,

why ten seconds??

Ok well i better shop around then. :raised_hands:

Yes you could use Background Functions, but the problem is, where will you clone the repo? You’d need some sort of disk space and file system to be able to process the files, read their contents and finally translate them. There might not be as easy way to do this.

Also functions are generally made to return some data to the client, so if you do get it to work, it won’t be in an ideal way. With that being said, if you do figure out, do share it with the forums to help others.