An open API service indexing awesome lists of open source software.

https://github.com/decathlon/gradle-plugin-phraseapp

Gradle plugin to push and pull translations on a Phrase project
https://github.com/decathlon/gradle-plugin-phraseapp

gradle hacktoberfest kotlin phrase plugin translations

Last synced: 4 months ago
JSON representation

Gradle plugin to push and pull translations on a Phrase project

Awesome Lists containing this project

README

        

# PhraseApp Plugin

client module is a java library which allows you to communicate with the PhraseApp API.

api-gradle is the Gradle plugin which have the client as dependency.

## Tasks

- `phraseClean` starts task to clean all local resources.
- `phraseDownload` starts task to download string resources.
- `phraseUpload` starts task to upload a string resource.
- `phraseCheck` starts task to apply all phrase checks (see bellow).
- `phraseDuplicateKeysCheck` starts task to check if there are duplicate keys in res folder.
- `phrasePluralsCheck` starts task to check if plural strings are well formatted.
- `phrasePlaceHolderCheck` starts task to check if placeholders aren't removed in other locale string resource folders.

## Parameters

When you want to use this plugin, you need to specify some mandatory parameters and you can customize
the execution of the parameters with optional parameters.

### Mandatory

**Kotlin**

```kotlin
import phrase.phrase

apply {
plugin("com.decathlon.phrase")
}

phrase {
authToken.set("token ")
projectId.set(">")
mainLocaleId.set(">")
resFolders.set(arrayListOf("path_to_res_folder"))
}
```

**Groovy**

```groovy
apply plugin: 'com.decathlon.phrase'

phrase {
// Authentication token used to communicate with PhraseApp.
authToken = 'token '

// Project id of your PhraseApp project.
projectId = ''

// Identifier of the default locale.
mainLocaleId = ''

// Target locations to print all translations from PhraseApp.
resFolders = ['']
}
```

If one of your resource folder have multiple strings files, you can use `resFoldersMultiStrings`
property:

**Kotlin**
```kotlin
phrase {
resFoldersMultiStrings.set(
mapOf(
"${project.projectDir.absolutePath}/src/main/res"
to arrayListOf("strings.xml, strings_2.xml", "strings_3.xml")
)
)
}
```

**Groovy**

```groovy
def resFolders = [:]
resFolders.put(
project.projectDir.absolutePath + '/src/main/res',
[ "strings.xml", "strings_2.xml", "strings_3.xml" ]
)

phrase {
// mandatory fields...

resFoldersMultiStrings = resFolders
}
```

### Optional

**Kotlin**

```kotlin
phrase {
// mandatory fields...

// Generate the output adapted to the platform. Can be 'ANDROID', soon 'IOS' and 'FLUTTER'
platform.set(phraseapp.internal.Platform.ANDROID)

// Download the default locale from PhraseApp and write it on the disk with the download task. Default: false.
overrideDefaultFile.set(false)

// phrase base url to consume phrase API. Default value: https://api.phraseapp.com/api
phraseBaseUrl.set("")

// If you aren't interested by the json file generated by the download task, you don't need to fill this property.
outputLocation.set("")

// If you want to convert a PhraseApp locale to your custom locale, add it into this map.
// For example: ['zh-CN': 'zh-Hans']
exceptions.set(mapOf())

// If you want to convert all placeholder into your platform's placeholder, switch this parameter to true. Default: false.
placeholder.set(false)

// If you want to specify your custom locale in the name of a PhraseApp locale, you can specify the regex of your PhraseApp locale name here. Default: .+_([a-z]{2}-[A-Z]{2})
localeNameRegex.set("")

// If you want to omit translation comments imported by the download task. Default: false
ignoreComments.set(false)

// If you want to import only some locales during the download task. Skip param to fetch all locales.
// For example: ['cs-CZ', 'fr-FR', 'de-DE']
allowedLocaleCodes.set(listOf(""))
}
```

**Groovy**

```groovy
phrase {
// mandatory fields...

// Generate the output adapted to the platform. Can be 'ANDROID', soon 'IOS' and 'FLUTTER'
platform = ''

// Download the default locale from PhraseApp and write it on the disk with the download task. Default: false.
overrideDefaultFile = false

// Phrase base url to consume phrase API. Default value: https://api.phraseapp.com/api
phraseBaseUrl = ""

// If you aren't interested by the json file generated by the download task, you don't need to fill this property.
outputLocation = ""

// If you want to convert a PhraseApp locale to your custom locale, add it into this map.
// For example: ['zh-CN': 'zh-Hans']
exceptions = [:]

// If you want to convert all placeholder into your platform's placeholder, switch this parameter to true. Default: false.
placeholder = false

// If you want to specify your custom locale in the name of a PhraseApp locale, you can specify the regex of your PhraseApp locale name here. Default: .+_([a-z]{2}-[A-Z]{2})
localeNameRegex = ""

// If you want to omit translation comments imported by the download task. Default: false
ignoreComments = false

// If you want to import only some locales during the download task. Skip param to fetch all locales.
// For example: ['cs-CZ', 'fr-FR', 'de-DE']
allowedLocaleCodes = [""]
}
```

## Download

```kotlin
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.decathlon.phrase:phrase-gradle-plugin:")
}
}
```

Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].

## License

Copyright 2021 Decathlon.

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.

[snap]: https://oss.sonatype.org/content/repositories/snapshots/com/decathlon/phrase/