A gradle plugin to manage texts from WS or csv hosted as google sheet
Add to your build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.mrroboaat:texts-manager:1.1.0'
}
}
apply plugin: 'com.mrroboaat'
android {
// ...
texts {
// ...
}
}
## Webservice
This library download text from ws. Language is sent as header to API. Model should be as json like following :
{
"data": {
"texts": [
{
"key": "my_key",
"value": "My Value"
},
{
"key": "other_key",
"value": "Other wonderful value"
}
]
}
}
Plugin will produce the following lines and create right xml files if it does not exist
<string name="my_key">My Value</string>
TODO : Explain how to get client_secret.json form google API console
Go to https://console.developers.google.com Enable google sheets API
Your sheet should look like :
You have to distinguish 2 use case :
texts {
defaultLanguage = 'en'
languages = ['de', 'es', 'fr']
ws = 'http://hostname/text'
missingKeys = '''
<!-- other resources (not present in WS) -->
<string name="app_name">appName</string>
<string name="dontforget">Don\'t Forget</string>
'''
...
}
Don't forget to escape your special characters
texts {
defaultLanguage = 'en'
languages = ['en', 'fr']
gSpreadsheetId = '1yrV86y7UixUWNZUj5nwnWLePzZnDdwLTSuIAcbgFIZs'
gSheetClientSecret = '/home/antoine/Desktop/client_secret.json'
// A = 0, B = 1, ...
gColumnIndexForKey = 1
gColumnIndexForValue = 2
}
defaultLanguage
: Your default languagelanguages
: All languages available for the appws
: Where you can retrieve texts as jsongSpreadsheetId
: Identifier of google sheetgSheetClientSecret
: Path to account servicegColumnIndexForKey
: Index from google sheet where we can get keysgColumnIndexForValue
: Index from google sheet where we can get valuesmissingKeys
: Keys you want to add (not in WS or google sheet)removeDuplicate
: Remove all duplicates keys (default is yes)alphabeticallySort
: Use alphabetical sort on the keys (default is yes)removeBadKeys
: Remove keys which contains white space (default yes)