-
Notifications
You must be signed in to change notification settings - Fork 1
Generate for Android Project
wiki de pasquale edited this page Jun 16, 2023
·
5 revisions
You need a following script in your project repository:
#!/bin/bash
AndroidModule="app"
GoogleSheetID="<sheet-id>"
GoogleSheet="<sheet-key>"
GoogleSpreadsheet="https://docs.google.com/spreadsheets/d/$GoogleSheetID/gviz/tq?tqx=out:csv&sheet=$GoogleSheet"
OutputDirectoryDebug="../$AndroidModule/build/generated/res/resValues/debug"
OutputDirectoryRelease="../$AndroidModule/build/generated/res/resValues/release"
## Download a CSV
wget -q -O keys.csv -c $GoogleSpreadsheet
## Update generate translation files
bash dragapultw generate -i keys.csv -s csv -o $OutputDirectoryDebug -t android
bash dragapultw generate -i keys.csv -s csv -o $OutputDirectoryRelease -t android
$AndroidModule="app"
$GoogleSheetID="<sheet-id>"
$GoogleSheet="<sheet-key>"
$GoogleSpreadsheet="https://docs.google.com/spreadsheets/d/$GoogleSheetID/gviz/tq?tqx=out:csv&sheet=$GoogleSheet"
$OutputDirectoryDebug="../$AndroidModule/build/generated/res/resValues/debug"
$OutputDirectoryRelease="../$AndroidModule/build/generated/res/resValues/release"
wget -OutFile keys.csv $GoogleSpreadsheet
$Processes = $(
Start-Process dragapult.exe -NoNewWindow -ArgumentList "generate -b -i keys.csv -s csv -o $OutputDirectoryDebug -t android" -PassThru;
Start-Process dragapult.exe -NoNewWindow -ArgumentList "generate -b -i keys.csv -s csv -o $OutputDirectoryRelease -t android" -PassThru;
)
$Processes | Wait-Process
And after that you need to modify your root build.gradle with the following statements:
tasks.register('generateLocalization', Exec) {
workingDir "${projectDir}/localization"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'powershell', '-File', 'update-locale.ps1'
} else {
commandLine 'zsh', 'update-locale.sh'
}
}
subprojects {
preBuild {
dependsOn(generateLocalization)
}
}
macOS has ZSH as its default shell, for unix based systems you will be required to install the Z shell If you encounter such issue on CI's ubuntu, simply run
sudo apt install -y zsh
before running your build
Thereafter you can open Gradle tab in IntelliJ/Android Studio and find generateLocalization
task. Right click it and select After Sync
. It will automatically generate the resources for your app.