Small script for translator (for local work)
Posted: Sat Apr 16, 2022 4:30 pm
As described in the wiki, there are scripts to work with translation files, upload them to the server, and update the translations in a branch. They work great, but there is one problem (for me). They need admin rights of the crowdin.com server to work.
As a small translator, I had a problem with the update of the translation in the freecad program. I like to see and edit translations as necessary, depending on how they look in the program itself. My language (Ukrainian) is context sensitive.
It's all lyrics. So I'll get down to business.
A script was written that updates the translation files in the program. The source file is the downloaded archive from the server. It's look like FreeCAD $Your_Language_CODE.zip
There are 3 variables in the script, 2 language codes, with capital and small letters, and the location of the directory with FreeCAD source. They can be changed according to your needs.
I am not a great programmer and not a great translator (I can write with errors in English), but the script seems to work. Use at your own risk.
To rerun script you need empty temporary directory FreeCAD_$lang_Code_Upper_Case. I don't found where Complete.ts, draft.ts, Ship.ts Plot.ts is placed and ignore it.
As a small translator, I had a problem with the update of the translation in the freecad program. I like to see and edit translations as necessary, depending on how they look in the program itself. My language (Ukrainian) is context sensitive.
It's all lyrics. So I'll get down to business.
A script was written that updates the translation files in the program. The source file is the downloaded archive from the server. It's look like FreeCAD $Your_Language_CODE.zip
There are 3 variables in the script, 2 language codes, with capital and small letters, and the location of the directory with FreeCAD source. They can be changed according to your needs.
I am not a great programmer and not a great translator (I can write with errors in English), but the script seems to work. Use at your own risk.
Code: Select all
# define language code here
lang_Code="uk"
lang_Code_Upper_Case="UK"
FreeCAD="FreeCAD"
#Make directory for extracted files
mkdir -p FreeCAD_$lang_Code_Upper_Case
#Unzip archive to directory
unzip "FreeCAD ($lang_Code).zip" -d FreeCAD_$lang_Code_Upper_Case
echo "Preparing files"
#rename all files in directory
cd FreeCAD_$lang_Code_Upper_Case
rename 's/.ts$//' *.ts
ls | xargs -I {} mv {} {}_$lang_Code.ts
rm homepage.po_$lang_Code.ts
echo "Start creating qm files"
#Create qm files for all ts
lrelease *.ts
#Update ts in FreeCAD tree
echo "Copying translation files in defined place"
cp AddonManager_$lang_Code.* ~/$FreeCAD/src/Mod/AddonManager/Resources/translations/
cp Arch_$lang_Code.* ~/$FreeCAD/src/Mod/Arch/Resources/translations
cp Assembly_$lang_Code.* ~/$FreeCAD/src/Mod/Assembly/Gui/Resources/translations
#Complete_$lang_Code.ts
#draft_$lang_Code.ts
cp Drawing_$lang_Code.* ~/$FreeCAD/src/Mod/Drawing/Gui/Resources/translations
cp Fem_$lang_Code.* ~/$FreeCAD/src/Mod/Fem/Gui/Resources/translations
cp FreeCAD_$lang_Code.* ~/$FreeCAD/src/Gui/Language
cp Image_$lang_Code.* ~/$FreeCAD/src/Mod/Image/Gui/Resources/translations
cp MeshPart_$lang_Code.* ~/$FreeCAD/src/Mod/MeshPart/Gui/Resources/translations
cp Mesh_$lang_Code.* ~/$FreeCAD/src/Mod/Mesh/Gui/Resources/translations
cp OpenSCAD_$lang_Code.* ~/$FreeCAD/src/Mod/OpenSCAD/Resources/translations
cp PartDesign_$lang_Code.* ~/$FreeCAD/src/Mod/PartDesign/Gui/Resources/translations
cp Part_$lang_Code.* ~/$FreeCAD/src/Mod/Part/Gui/Resources/translations
cp Path_$lang_Code.* ~/$FreeCAD/src/Mod/Path/Gui/Resources/translations
#Plot_$lang_Code.ts
cp Points_$lang_Code.* ~/$FreeCAD/src/Mod/Points/Gui/Resources/translations
cp Raytracing_$lang_Code.* ~/$FreeCAD/src/Mod/Raytracing/Gui/Resources/translations
cp ReverseEngineering_$lang_Code.* ~/$FreeCAD/src/Mod/ReverseEngineering/Gui/Resources/translations
cp Robot_$lang_Code.* ~/$FreeCAD/src/Mod/Robot/Gui/Resources/translations
#Ship_$lang_Code.ts
cp Sketcher_$lang_Code.* ~/$FreeCAD/src/Mod/Sketcher/Gui/Resources/translations
cp Spreadsheet_$lang_Code.* ~/$FreeCAD/src/Mod/Spreadsheet/Gui/Resources/translations
cp StartPage_$lang_Code.* ~/$FreeCAD/src/Mod/Start/Gui/Resources/translations
cp TechDraw_$lang_Code.ts ~/$FreeCAD/src/Mod/TechDraw/Gui/Resources/translations
cp Test_$lang_Code.ts ~/$FreeCAD/src/Mod/Test/Gui/Resources/translations
cp Tux_$lang_Code.ts ~/$FreeCAD/src/Mod/Tux/Resources/translations
cp Web_$lang_Code.ts ~/$FreeCAD/src/Mod/Web/Gui/Resources/translations
echo "Finish. Now you may re-build FreeCAD to see updated translation for $lang_Code_Upper_Case language"