Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.dkorobtsov:poeditor-gradle:0.3.3'
}
dependencies {
implementation("com.github.dkorobtsov:poeditor-gradle:0.3.3")
}
<dependency>
<groupId>com.github.dkorobtsov</groupId>
<artifactId>poeditor-gradle</artifactId>
<version>0.3.3</version>
</dependency>
libraryDependencies += "com.github.dkorobtsov" % "poeditor-gradle" % "0.3.3"
:dependencies [[com.github.dkorobtsov/poeditor-gradle "0.3.3"]]
Gradle plugin to manage translations easily within a POEditor project. The plugin enables you to include downloading and uploading of translations in your Gradle build file.
This gradle plugin depends on poeditor-java, a java client for the POEditor API.
Add the following 2 lines of code to your gradle.build
file.
In the buildscript dependencies
section:
maven { url = 'https://jitpack.io' }
In the dependencies
section:
classpath "com.github.dkorobtsov:poeditor-gradle:-SNAPSHOT"
Include the plugin:
apply plugin: 'poeditor'
The plugin requires at minimum Java 7 and Gradle 2.x.
Add configuration about your POEditor project to the gradle.build
file. You need an api key and project id from
POEditor.
Example configuration:
poeditor {
apikey 'your api key here'
projectId 'your project id here'
type 'android_strings'
tagsNew '1.0'
terms 'App/src/main/res/values/strings.xml'
trans 'en', 'App/src/main/res/values/strings.xml'
trans 'nl', 'App/src/main/res/values-nl/strings.xml'
trans 'fr', 'App/src/main/res/values-fr/strings.xml'
filters 'nl', 'translated'
filters 'fr', 'translated, automatic'
}
Parameter | Description ------------ | -------------------- apiKey | api key to access the api, can be obtained in your Account projectId | id of the project on POEditor type | file format: po, pot, mo, xls, apple_strings, xliff, android_strings, resx, resw, properties, json terms | point to the file that contains all the terms, probably this is your default language trans | receives 2 parameters: language code & file path of a translation filters | receives 2 parameters: language code & comma separated list of filters. Check the API Reference for all available filters
Now you're all set to manage your translations.
If you need flavor depending values, the setup is similar
configure the shared values:
poeditor {
apikey 'your api key here'
projectId 'your project id here'
type 'android_strings'
tagsNew '1.0'
}
and keep the translation values in the flavors:
productFlavors {
'myflavor' {
...
project.poeditor {
variant 'myflavor'
projectId 'your project id here'
terms 'App/src/main/res/values/strings.xml'
trans 'en', 'App/src/myflavor/res/values/strings.xml'
trans 'nl', 'App/src/myflavor/res/values-nl/strings.xml'
trans 'fr', 'App/src/myflavor/res/values-fr/strings.xml'
filters 'nl', 'translated'
filters 'fr', 'translated, automatic'
}
}
}
in case plugin is used in non-Android project, flavors can be added using sourceSets:
apply java before poeditor:
apply plugin: 'java'
and keep the translation values in the sourceSets:
sourceSets {
'myflavor' {
...
project.poeditor {
variant 'myflavor'
projectId 'your project id here'
terms 'App/src/main/res/values/strings.xml'
trans 'en', 'App/src/myflavor/res/values/strings.xml'
trans 'nl', 'App/src/myflavor/res/values-nl/strings.xml'
trans 'fr', 'App/src/myflavor/res/values-fr/strings.xml'
filters 'nl', 'translated'
filters 'fr', 'translated, automatic'
}
}
}
After your have created your translation project on POEditor you can can initialize your project based on your c onfiguration.
gradle poeditorInit
This will create terms and add languages to your project.
gradle poeditorPull
gradle poeditorPush
Argument | Description --------------- | ---------------------------------------------------------------------- languages | specify the languages that you want to upload, by default everything is uploaded override | force to override the translation on POEditor
Example:
gradle poeditorPush -Planguages=nl,fr -Poverride=true
gradle poeditorPushTerms
A few example configurations can be found in the example projects folder.
For flavors use the same tasks but add the flavor name:
Example:
gradle poeditorPushmyflavor
Copyright 2015 Maarten Huijsmans
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.