The custom processors enable developers to implement their own middleware server, and implement custom workflows and integrations into the process of importing and exporting translation content.
By creating a custom processing server, and connecting it to Lokalise, developers can manipulate data, connect to 3rd-party services, and introduce their own custom logic into the processes.
Here’s a technical overview of how the processors work and interact with Lokalise:
An easy way to understand what the custom processors are, is to imagine them as pipes, through which data is passed before it’s saved in Lokalise, and then again when it’s being exported back into files:
You know how sometimes you only need to make a little change in the processing logic, but can’t find an elegant way to do that?
You know the feeling of wishing you could just add a “yes, but…” function into a process?
With Lokalise, dreams do come true, and with the Custom Processors, the use cases are only limited by your imagination.
Here are a few examples of problems, and solutions, that can be implemented with a custom processor:
- Validators - ensuring that banned words never reach production.
- Superscript Processing - for using keys in different frameworks (such as iOS and Android).
- Pre/Post Processing - standardising symbols such as spaces and quotes across different file formats.
- Markup Conversation - converting HTML to Markdown (or any other language) is easy peasy.
- QA and MT integrations - connect to any 3rd-party API during processing to enrich the data.
Sounds like fun? it sure is! read on to learn how to build, implement, and connect Lokalise to your very own custom processor.
To use a custom processor you’ll need 2 things:
- A server that will receive the data, process it, and return it (don’t worry - we have a boilerplate server to get you started in just a few minutes).
- To install the Custom processor App, and configure it to connect to your server.
To help you speed up the implementation, we provide a repository with a boilerplate server, that is preconfigured to work with the custom processor API: Custom processor boilerplate repository
Click the below button to deploy a sample Custom processor App on Heroku in a few seconds:
Note: If you don't have an account on Heroku, you need to sign up on Heroku. Once you sign up, you'll be redirected to your Heroku app creation page.
To get started, simply fork the repository, and out of the box you’ll get:
- A deployable server based on Fastly, with Docker and a Procfile preconfigured for easy deployment.
- Prebuilt routes for pre-processing and post-processing, ready to be connected to Lokalise.
- Boilerplate code for the processing functions, that already shows how to iterate and process the payload.
After deploying the server to a web accessible hosting provider, your next step would be to customize the business logic of the processing functions. That’s where you can get creative, integrate other services, and perform any operation on the data that was sent for processing.
When you’re ready to test it out, head over to the Apps page in your Lokalise project, and install the Custom processor app. To configure the App, you’ll need to define 3 values:
- The URL for pre-processing - That’s the location of the pre-processing endpoint of the deployed server.
- The URL for post-processing - Same, but for the post-processing.
- File Formats - If you wish, you can limit the processors to only interact with data from specific file formats.
And that’s it - you’re ready to test it out!
To see it in action, simply upload a file with keys (you can use the UI, API, or CLI for that), and you’ll see the result of your processing function in Lokalise. Some call this magic. we call it Extensibility.
Check out more Lokalise custom processor: Sample apps.
Updated about 1 year ago