Skrypty Crowdin

From FreeCAD Documentation
Revision as of 18:22, 6 May 2021 by Kwahoo (talk | contribs)

Zarządzanie Tłumaczeniami w FreeCAD

FreeCAD do zarządzania tłumaczeniami używa zewnętrznego serwisu nazywanego Crowdin.

W FreeCAD/src/Tools znajdują się 3 skrypty, które służą do zarządzania plikami tłumaczeń:

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

Uwagi

  • Skrypty te uruchamiane są z głównego katalogu FreeCAD/.
  • By umożliwić działanie tych skryptów musisz mieć prawidłowy klucz FreeCAD Crowdin API umieszczony w swoim pliku key ~/.crowdin-freecad. (Z powodów bezpieczeństwa jest tylko dostępny dla ludzi z prawami administratora na stronie Crowdin FreeCAD)
  • Obecnie te narzędzia są kompatybilne z Pythonem 2.

updatets.py

Skrypt updatets.py utworzy pliki .ts w twoim lokalnym katologu FreeCAD/. Generuje on pliki .ts (Plik Źródłowy Tłumaczenia Qt).

Jest wywoływany przez: python2 updatets.py

updatecrowdin.py

Skrypt updatecrowdin.py ładuje zmiany do Crowdin (zewnętrznego serwisu tłumaczeń społecznościowych) z twojego lokalnego katalogu FreeCAD/. Obecnie skrypt obsługuje 4 argumenty:

  • updatecrowdin.py status wypisuje stan tłumaczeń
  • updatecrowdin.py update aktualizuje Crowdin aktualną wersją plików .ts znalezioną w kodzie źródłowym
  • updatecrowdin.py build buduje na Crowdin nową, możliwą do pobrania paczkę z wszystkimi przetłumaczonymi ciągami tekstowymi
  • updatecrowdin.py download pobiera najnowszą paczkę

updatefromcrowdin.py

Skrypt updatefromcrowdin.py ściąga zmiany z Crowdin do twojego lokalnego katalogu FreeCAD/.

By wysłać najnowsze zwroty do Crowdin

  • Przetestowane tylko na Linuksie
  • Potrzebujesz pliku .credentials w twoim katalogu /home/TwójUżytkownik. Plik ten jest prostym plikiem tekstowym zawierającym tylko jedną linię, którą jest klucz API otrzymywany na https://crowdin.com/project/freecad/settings#api (tylko dla administratorów)
  • Upewnij się, że twoje repozytorium jest czyste (git pull, git stash jeśli to konieczne)
  • cd /path/to/freecad-source-code/src/Tools
  • python updatets.py (wypełni najnowszymi ciągami tekstowymi wszystkie pliki .ts znalezione w źródłach)
  • python updatecrowdin.py update (wyśle pliki .ts do Crowdin. Crowdin zaktualizuje tylko nowe ciągi tekstowe)
  • cd ../.. (idź z powrotem go głównego katalogu źródeł)
  • git checkout . (cofnij wszystkie zmiany w plikach .ts, nie ma powodu by wprowadzać je już teraz gdy są wciąż nieprzetłumaczone)

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 repository 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
  • Create a PR on FreeCAD

To generate a translation file from the website

  • Clone the homepage repository
  • cd /path/to/FreeCAD-homepage
  • xgettext --from-code=UTF-8 -o lang/homepage.pot *.php
  • Update the "homepage.po" on crowdin website manually, using the lang/homepage.pot file

To update the translations of the website

  • Get the freecad.zip file either by downloading it from the crowdin website or following instructions above (python updatecrowdin.py download)
  • cd /path/to/FreeCAD-homepage
  • Make sure your repository is clean (git pull, git stash if needed)
  • python updatefromcrowdin.py -z /path/to/freecad.zip
  • 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
  • Create a PR on FreeCAD-Homepage
  • After the PR is merged, one of the admins will ftp push to the webhost

Related