How regularly is the archive with translations in crowdin updates?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
kisolre
Posts: 3344
Joined: Wed Nov 21, 2018 1:13 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by kisolre »

Evgeniy wrote: Thu Sep 09, 2021 10:24 pm Much faster and better variant with using subprocess:
So I ran that script...
First, why does it search for lrelease.exe in the FreeCAD userdata folder? I dont know why but I have it in my localbuild bin folder. I copied it to the userdata folder for the script to run.
Second, I translated some strings in Crowdin, ran the script in FreeCAD, restarted FreeCAD, but the strings that were newly translated are still in english in the interface. There are recent .qm files generated in translations folder but they are not used or they dont contain the newly translated strings.
Am I doing something wrong?

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.20.25695 (Git)
Build type: Release
Branch: master
Hash: 582c26ea8b5f9d85957a6cb1bf798839fa2ce94c
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Bulgarian/Bulgaria (bg_BG)
Evgeniy
Posts: 315
Joined: Thu Jul 15, 2021 6:10 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by Evgeniy »

kisolre wrote: Sat Sep 11, 2021 7:30 pm
Evgeniy wrote: Thu Sep 09, 2021 10:24 pm Much faster and better variant with using subprocess:
So I ran that script...
First, why does it search for lrelease.exe in the FreeCAD userdata folder? I dont know why but I have it in my localbuild bin folder. I copied it to the userdata folder for the script to run.
Second, I translated some strings in Crowdin, ran the script in FreeCAD, restarted FreeCAD, but the strings that were newly translated are still in english in the interface. There are recent .qm files generated in translations folder but they are not used or they dont contain the newly translated strings.
Am I doing something wrong?
The fact is that the archive is updated manually after some time. The changes that you have made recently are not reflected there.
However, if you download ts files one at a time from Crowdin (there is such a possibility), they will already be with new edits.

In principle, can specify any path, I do not know how to get the path to the bin folder, so I used the path to userdata.

Has the assembled Windows version with Bulgarian language support already appeared on the Internet?
kisolre
Posts: 3344
Joined: Wed Nov 21, 2018 1:13 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by kisolre »

Evgeniy wrote: Sat Sep 11, 2021 8:31 pm Has the assembled Windows version with Bulgarian language support already appeared on the Internet?
Latest 25645 still does not have it.
Evgeniy wrote: Sat Sep 11, 2021 8:31 pm However, if you download ts files one at a time from Crowdin (there is such a possibility), they will already be with new edits.
Could this be made in another script to update only specific language by retrieving the .ts files directly?
User avatar
kaktus
Posts: 477
Joined: Sun Aug 11, 2019 11:59 am
Location: opolskie
Contact:

Re: How regularly is the archive with translations in crowdin updates?

Post by kaktus »

:idea:
I think more needed than new options are human resources, to help with GUI translation issues.

https://github.com/FreeCAD/FreeCAD-translations/issues
wierny padawan mistrza arturromarr
Twórca polskiej wersji Wiki dla FreeCAD, współwórca polskiej wersji GUI.
"Cierpliwym być musisz, by wiedzę zgłębiać tajemną, gdyż ciemna strona mocy niszczącą i silną jest".
Evgeniy
Posts: 315
Joined: Thu Jul 15, 2021 6:10 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by Evgeniy »

kisolre wrote: Sat Sep 11, 2021 11:27 pm
Evgeniy wrote: Sat Sep 11, 2021 8:31 pm However, if you download ts files one at a time from Crowdin (there is such a possibility), they will already be with new edits.
Could this be made in another script to update only specific language by retrieving the .ts files directly?
I can do it, but you say that Bulgarian is not supported yet. How do you use it now?
If the script creates FreeCAD_bg.qm then FreeCAD will simply not see it.

Did you build FreCAD for Windows by yourself?
Last edited by Evgeniy on Sun Sep 12, 2021 9:45 am, edited 1 time in total.
kisolre
Posts: 3344
Joined: Wed Nov 21, 2018 1:13 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by kisolre »

kaktus wrote: Sun Sep 12, 2021 8:17 am I think more needed than new options are human resources,
That was my point - if it is hard to see/use your contribution why make it at all? Now I can use Bulgarian and the untranslated/badly translated items will poke constantly and I at least could invest some time to translate something :) But in the past I translated some items, but since I could not see/use them I quickly gave up.
Evgeniy wrote: Sun Sep 12, 2021 8:26 am Did you build FreCAD for Windows by yourself?
Yes, and that is what I regularly use. I just tested the latest LP build because You asked :)
Any idea how regularly is the ZIP archive created?
Evgeniy wrote: Sun Sep 12, 2021 8:26 am Of course, you can do it,
No idea how :) Could you create such script?
Evgeniy
Posts: 315
Joined: Thu Jul 15, 2021 6:10 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by Evgeniy »

kisolre wrote: Sun Sep 12, 2021 8:57 am No idea how :) Could you create such script?
Это была опечатка переводчика... Я имел ввиду, что могу подправить код :)

Code ready.
The path to the *.ts files must be without spaces
Put *.ts to User_folder\ts folder
You can place *.ts file in subfolder. For example \ts\Bulgarian\
locale ("any_file_bg.qm" for Bulgarian) getted from xml text of each *.ts file.

Code: Select all

#! python
# -*- coding: utf-8 -*-
# <nowiki>(c) 2021 <Evgeniy> LGPL

import sys, os, zipfile, re
import urllib.request
import subprocess

# 1. Get path to $USER/AppData/Roaming/FreeCAD/ folder
path = App.getUserAppDataDir()
trans_path = os.path.join(path,"translations")
ts_path = os.path.join(path,"ts")
# Create translation and FreeCAD_zip folder if it not exists
os.makedirs(trans_path, exist_ok = True)
os.makedirs(ts_path, exist_ok = True)
print("Copy youre *.ts files to folder: "+ts_path)
print("And run this script")
print("You can use subfolders in \ts folder! But path does not contain space chars!")

# 2. Check lrealase.exe utility in folder
lrel_path = os.path.join(path,"lrelase.exe")
if not os.path.exists(trans_path.replace("translations","lrelease.exe")):
   print(lrel_path+" is not found... process stopped")
   print("please copy lrelease.exe utilty to folder: "+trans_path.replace("translations","")+" and try again!")
   sys.exit(-1)

def get_locale_from_file(path):
   file = open(path, "r", encoding="utf8")
   text = file.read()
   locale = re.search(r'" language="[^"]+"',text).group()
   locale = locale.replace('"','').replace(" language=","")
   file.close()
   return locale   

# 3. Make list of files
print("\nScan "+ts_path+" folder...")
file_list = []
supported_locales = Gui.supportedLocales().values()
os.chdir(path)
# Walk into FreeCAD unzipped folder and lrelease all files
for dirpath, subdirs, files in os.walk(ts_path):
   for file in files:
      if file.endswith(".ts"):
         file_path = os.path.join(dirpath, file)
         locale = get_locale_from_file(file_path)
         print(file_path+" ["+locale+"]")
         file_list.append((file,file_path,locale))
print(str(len(file_list))+" files will be converted\n")

# 4. Translate all files with lrelease
progress=0
for file_info in file_list:
   file_name,file_path,locale=file_info
   out_locale = locale #"de"
   #os.system("lrelease "+file_path)
   FreeCADGui.updateGui()
   subprocess.call("lrelease "+file_path, shell=True, cwd=path)
   qm_file_path=file_path.replace(".ts",".qm")
   if not os.path.exists(qm_file_path):
      print("ERROR: of creation " + qm_file_path + " file, it does not exist, aborting")
      sys.exit(-1)
   else:
      # Rename and move file
      qm_file_name=file_name.replace(".ts","_"+out_locale+".qm")
      qm_new_path=os.path.join(trans_path,qm_file_name)
      if os.path.exists(qm_new_path):
         FreeCADGui.updateGui()
         os.remove(qm_new_path) 
      os.rename(qm_file_path,qm_new_path)
      perc = 100/len(file_list)*progress
      print(" {0:6.2f}% ".format(perc) + file_path.replace(path,"") +" -> "+qm_file_name)
      FreeCADGui.updateGui()  
   progress+=1

# 5. Complete message
print("Integration of *.ts files complited!") 
Console result:

Code: Select all

   0.00% ts\AddonManager.ts -> AddonManager_bg.qm
   3.57% ts\Arch.ts -> Arch_bg.qm
   7.14% ts\Assembly.ts -> Assembly_bg.qm
  10.71% ts\Complete.ts -> Complete_bg.qm
  14.29% ts\draft.ts -> draft_bg.qm
  17.86% ts\Drawing.ts -> Drawing_bg.qm
  21.43% ts\Fem.ts -> Fem_bg.qm
  25.00% ts\FreeCAD.ts -> FreeCAD_bg.qm
  28.57% ts\Image.ts -> Image_bg.qm
  32.14% ts\StartPage.ts -> StartPage_bg.qm
  35.71% ts\TechDraw.ts -> TechDraw_bg.qm
  39.29% ts\Bulgarian\Mesh.ts -> Mesh_bg.qm
  42.86% ts\Bulgarian\MeshPart.ts -> MeshPart_bg.qm
  46.43% ts\Bulgarian\OpenSCAD.ts -> OpenSCAD_bg.qm
  50.00% ts\Bulgarian\Part.ts -> Part_bg.qm
  53.57% ts\Bulgarian\PartDesign.ts -> PartDesign_bg.qm
  57.14% ts\Bulgarian\Raytracing.ts -> Raytracing_bg.qm
  60.71% ts\Bulgarian\ReverseEngineering.ts -> ReverseEngineering_bg.qm
  64.29% ts\Bulgarian\Robot.ts -> Robot_bg.qm
  67.86% ts\Bulgarian\Ship.ts -> Ship_bg.qm
  71.43% ts\Bulgarian\Sketcher.ts -> Sketcher_bg.qm
  75.00% ts\Bulgarian\Test.ts -> Test_bg.qm
  78.57% ts\Bulgarian\Tux.ts -> Tux_bg.qm
  82.14% ts\Bulgarian\Web.ts -> Web_bg.qm
  85.71% ts\Other_folder\Path.ts -> Path_bg.qm
  89.29% ts\Other_folder\Plot.ts -> Plot_bg.qm
  92.86% ts\Other_folder\Points.ts -> Points_bg.qm
  96.43% ts\Other_folder\Spreadsheet.ts -> Spreadsheet_bg.qm
Integration of *.ts files complited!
Last edited by Evgeniy on Sun Sep 12, 2021 10:49 am, edited 2 times in total.
Evgeniy
Posts: 315
Joined: Thu Jul 15, 2021 6:10 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by Evgeniy »

kisolre wrote: Sun Sep 12, 2021 8:57 am
Evgeniy wrote: Sun Sep 12, 2021 8:26 am Did you build FreCAD for Windows by yourself?
Yes, and that is what I regularly use. I just tested the latest LP build because You asked :)
Intresting, you build by Wiki instructions?
I also did a build for Linux, https://forum.freecadweb.org/viewtopic.php?f=4&t=60272 but now there is no such possibility.
I don't want to use VS Studio, for building under Windows.
Although it doesn't make much sense. Updated builds are released periodically.

kisolre wrote: Sun Sep 12, 2021 8:57 am Any idea how regularly is the ZIP archive created?
I dont know. Ask to do that Yorik or Kunda1...
But I think there is no point in this 1 time every two weeks is more than enough. Moreover, there is not always an influx of translators.
Especially now that there is a script, this should cover the needs.
Evgeniy
Posts: 315
Joined: Thu Jul 15, 2021 6:10 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by Evgeniy »

kaktus wrote: Sun Sep 12, 2021 8:17 am :idea:
I think more needed than new options are human resources, to help with GUI translation issues.

https://github.com/FreeCAD/FreeCAD-translations/issues
I think i create a temporary github account and add a couple more offers there.
kisolre
Posts: 3344
Joined: Wed Nov 21, 2018 1:13 pm

Re: How regularly is the archive with translations in crowdin updates?

Post by kisolre »

Evgeniy wrote: Sun Sep 12, 2021 9:45 amCode ready.
Not to be ungrateful but my idea was more like a full automation of downloading all ts files for selected language one by one and converting to qm.
Evgeniy wrote: Sun Sep 12, 2021 9:51 am Intresting, you build by Wiki instructions?
Generally yes. But my latest solution is a clean Win10 VM with just the tools (VS, TortoiseGit, ...) necessary to build and Syncthing to move things to the host for regular usage.
Post Reply