LokEx is a utility tool to export strings from Lokalise using the REST API using a Jinja templating language. You can use it as Java library, CLI tool or gradle plugin
Features:
- Support for different languages per project
- Code generation using Jinja2 templating syntax for any code language
- Simple configuration
- Create a config file for your project, see the
sample/config.json - Create a Figma personal access token
- Run
export LOKALISE_TOKEN="your token" - Run
lokex -c "path to your config
- Apply the plugin
plugins {
apply("com.iodigital.lokex")
}- Configure the plugin
lokex {
lokaliseToken = File("...").readText().trim()
configFile = file("${configFile.absolutePath}")
}- Export using
./gradlew exportLokalise
exports: Defines the exports to be donelanguage: The language to be exportedplatform: One ofandroid,ios,webor `other. Used to filter the strings.exportEmptyAs: One ofbase(exports base language value) ornone(skips value)destinationPath: The file to which the generated code should be writtentemplatePath: The path for the template fileprojectId: The project ID, may be multiple separated by comma (works similar toincludeIdof the Lokalise CLI)includeProjectId: Optional, second project ID to includetemplateVariables: A map of extra variables for the template. If you definetesthere you can later use{{ test }}in your template file
The templating engine uses Jinja2 syntax. You can use loops, if statements and more.
strings: A list of String objectsplural: A list of Plurals objectslokalise: A figma file objectdate: The current date
name: A name objectvalue: The value of the stringplaceholders: A list of placeholder objects
name: A name objectvariants: A list of variant objectsplaceholders: A list of placeholder objects
quantity: The quantity, e.g.oneormanyvalue: The value of the string
index: The index of the placeholdertype: The type of the placeholder:Int,Double,String, orChar
Hint: You can also use Jinja filters to modify the name, e.g. {{ color.name|lowercase|replace("some", "other") }}
original: The name as defined in Figmasnake: The name in snake casekebab: The name in kebab casepascal: The name in pascal case
project_id: The Lokalise project IDlanguage: The language that was exported