Difference between revisions of "Crowdin Scripts"

From FreeCAD Documentation
Jump to navigation Jump to search
Line 22: Line 22:
 
=== updatefromcrowdin.py ===
 
=== updatefromcrowdin.py ===
 
This script pulls changes from crowdin to your local <code>FreeCAD/</code> directory.
 
This script pulls changes from crowdin to your local <code>FreeCAD/</code> directory.
 +
 +
== To send latest strings to crowdin ==
 +
 +
* Only tested on linux
 +
* You need a .credentials file in your /home/YourUser directory. That file is a simple text file containing only one line, which is the API key that you get on https://crowdin.com/project/freecad/settings#api (only for admins)
 +
* Make sure your repo is clean (git pull, git stash if needed)
 +
* cd /path/to/freecad-source-code/src/Tools
 +
* python updatets.py (will fill all the .ts files found in the source with the lastest strings)
 +
* python updatecrowdin.py update (will send the ts files to crowdin. Crowdin will only update strings that are new)
 +
* cd ../.. (go back to the source code root folder)
 +
* git checkout . (undo all the changes to the .ts files, no reason to commit them right now as they are still untranslated)
 +
 +
== To merge latest translations from crowdin ==
 +
 +
* Only tested on linux
 +
* You need a .credentials file in your /home/YourUser directory. That file is a simple text file containing only one line, which is the API key that you get on https://crowdin.com/project/freecad/settings#api (only for admins)
 +
* Make sure your repo is clean (git pull, git stash if needed)
 +
* cd /path/to/freecad-source-code/src/Tools
 +
* python updatecrowdin.py build (will create a zip on crowdin side with all the files, can take a while.. This step can also be done on the crowdin website)
 +
* python updatecrowdin.py download (will download a freecad.zip file in this directory)
 +
* mv freecad.zip ~ move the zip file to your home dir, to avoid accidentally committing it later)
 +
* (optional) edit updatefromcrowdin.py script and check that the default_languages contain all the ones you want (basically all that are at more than 50%)
 +
* python updatefromcrowdin.py -z /home/YourUser/freecad.zip
 +
* cd ../.. (go back to the source code root folder)
 +
* if something went wrong  or you are unsure, clean everything with git checkout .
 +
* if everything looks ok (git status), commit with git add . && git commit
  
 
== Related ==
 
== Related ==

Revision as of 00:49, 6 December 2018

Managing Translations for FreeCAD

FreeCAD uses a 3rd party translation service called Crowdin to manage translations.

There are 3 scripts in FreeCAD/src/Tools that are used to manage translation files:

  1. updatets.py (github source)
  2. updatecrowdin.py (github source)
  3. updatefromcrowdin.py (github source)

These scripts are run from the root of the FreeCAD/ directory. Note: In order for these scripts to work one needs to have the valid FreeCAD Crowdin API key placed in their ~/.crowdin-freecad file. (For security reasons, only available to people with admin rights on the crowdin FreeCAD project)

updatets.py

This script will create the .ts files in your local FreeCAD/ directory.

updatecrowdin.py

This script pushes changes to the Crowdin from your local FreeCAD/ directory. The script currently supports 4 arguments:

  • updatecrowdin.py status prints a status of the translations
  • updatecrowdin.py update updates crowdin the current version of .ts files found in the source code
  • updatecrowdin.py build builds a new downloadable package on crowdin with all translated strings
  • updatecrowdin.py download downloads the latest build

updatefromcrowdin.py

This script pulls changes from crowdin to your local FreeCAD/ directory.

To send latest strings to crowdin

  • Only tested on linux
  • You need a .credentials file in your /home/YourUser directory. That file is a simple text file containing only one line, which is the API key that you get on https://crowdin.com/project/freecad/settings#api (only for admins)
  • Make sure your repo is clean (git pull, git stash if needed)
  • cd /path/to/freecad-source-code/src/Tools
  • python updatets.py (will fill all the .ts files found in the source with the lastest strings)
  • python updatecrowdin.py update (will send the ts files to crowdin. Crowdin will only update strings that are new)
  • cd ../.. (go back to the source code root folder)
  • git checkout . (undo all the changes to the .ts files, no reason to commit them right now as they are still untranslated)

To merge latest translations from crowdin

  • Only tested on linux
  • You need a .credentials file in your /home/YourUser directory. That file is a simple text file containing only one line, which is the API key that you get on https://crowdin.com/project/freecad/settings#api (only for admins)
  • Make sure your repo is clean (git pull, git stash if needed)
  • cd /path/to/freecad-source-code/src/Tools
  • python updatecrowdin.py build (will create a zip on crowdin side with all the files, can take a while.. This step can also be done on the crowdin website)
  • python updatecrowdin.py download (will download a freecad.zip file in this directory)
  • mv freecad.zip ~ move the zip file to your home dir, to avoid accidentally committing it later)
  • (optional) edit updatefromcrowdin.py script and check that the default_languages contain all the ones you want (basically all that are at more than 50%)
  • python updatefromcrowdin.py -z /home/YourUser/freecad.zip
  • cd ../.. (go back to the source code root folder)
  • if something went wrong or you are unsure, clean everything with git checkout .
  • if everything looks ok (git status), commit with git add . && git commit

Related