Add crowdin CLI tool + my misc scripts, so I won't go crazy after all #431

This commit is contained in:
JustArchi
2017-02-20 17:41:29 +01:00
parent 92d6047631
commit 61985dbdc9
10 changed files with 103 additions and 0 deletions

3
.gitignore vendored
View File

@@ -22,6 +22,9 @@ GUI/debug
# Ignore out
out/
# Crowdin CLI secret
tools/crowdin-cli/crowdin_identity.yaml
#################
## Visual Studio
#################

View File

@@ -1,3 +1,4 @@
"preserve_hierarchy": true
files:
- source: /ArchiSteamFarm/Localization/Strings.resx
translation: /ArchiSteamFarm/Localization/Strings.%locale%.resx

View File

@@ -0,0 +1,35 @@
Crowdin CLI
===================
**[Latest release](https://crowdin.com/downloads/crowdin-cli.zip)**
**[Source](https://github.com/crowdin/crowdin-cli-2)**
**[Help](https://support.crowdin.com/cli-tool/#cli-2)**
===================
This tool is being used by ASF developers for synchronization of strings/translations between GitHub and **[Crowdin](https://github.com/JustArchi/ArchiSteamFarm/wiki/Localization)**. If you're not ASF developer that has access to our localization platform, then you won't find anything interesting here.
===================
## Before you begin
Make sure that your ```crowdin_identity.yaml``` file exists - this is the file with login credentials that is not being committed to GitHub. If it doesn't exist yet (e.g. because you've just cloned the repo), create it from ```crowdin_identity_example.yaml``` and fill ```api_key```.
Ensure that ```crowdin``` command is recognized by your OS.
===================
### Windows
- Install **[Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)**.
- **[Set JAVA_HOME properly](https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html)**
- Launch ```setup_crowdin.bat``` as administrator
- Open new ```cmd``` prompt and verify that ```crowdin help``` indeed works
===================
## Usage
```archi_download.bat``` for downloading translations from Crowdin (typically last commit before release)
```archi_upload.bat``` for pushing strings to Crowdin (when any *Strings.resx file gets modified)

View File

@@ -0,0 +1,4 @@
@echo off
cd ..\\..
call crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yaml download
pause

View File

@@ -0,0 +1,4 @@
@echo off
cd ..\\..
call crowdin -b master --identity tools\\crowdin-cli\\crowdin_identity.yaml upload sources
pause

Binary file not shown.

View File

@@ -0,0 +1,2 @@
@echo off
IF "%CROWDIN_HOME%"=="" (ECHO crowdin is NOT defined) ELSE (java -jar %CROWDIN_HOME%\crowdin-cli.jar %*)

View File

@@ -0,0 +1,26 @@
if type -p java; then
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
_java="$JAVA_HOME/bin/java"
else
echo "Looks like JAVA is not installed. You can download it from https://www.java.com/"
fi
if [[ "$_java" ]]; then
version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ "$version" > "1.7" ]]; then
echo Your Java version is "$version" - OK
sudo cp crowdin-cli.jar /usr/local/bin
echo alias crowdin="'java -jar /usr/local/bin/crowdin-cli.jar'" >> ~/.bashrc
echo alias crowdin="'java -jar /usr/local/bin/crowdin-cli.jar'" >> ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
else
echo Your Java version is "$version" - needs to be updated. You can download it from https://www.java.com/
fi
fi

View File

@@ -0,0 +1,2 @@
"project_identifier": "archisteamfarm"
"api_key": "FILL_ME"

View File

@@ -0,0 +1,26 @@
@echo off
SETLOCAL
SET TEMPFILE=%TEMP%\tmpfile
setx /M CROWDIN_HOME "%cd%"
setx /M PATH "%PATH%;%cd%"
IF NOT EXIST "%JAVA_HOME%\bin\java.exe" (
ECHO Looks like JAVA is not installed
)
"%JAVA_HOME%\bin\java" -version 2>& 1 | FIND "java version" > %TEMPFILE%
SET /p VERSIONSTRING= < %TEMPFILE%
DEL %TEMPFILE%
SET MAJORVERSION=%VERSIONSTRING:~14,1%
SET MINORVERSION=%VERSIONSTRING:~16,1%
SET UPDATEVERSION=%VERSIONSTRING:~20,-1%
IF %MAJORVERSION% GTR 1 GOTO VALID
IF %MINORVERSION% GTR 7 GOTO VALID
IF %UPDATEVERSION% GTR 0 GOTO VALID
ECHO Your JAVA version should be updated. You can download it from https://www.java.com/
GOTO EXIT
:EXIT
ENDLOCAL