Git commit 11364ad8deb4dadac94239a39337dd40d91ef22f by Boudewijn Rempt. Committed on 15/10/2020 at 09:54. Pushed by rempt into branch 'rempt/copy_po_files'. Add a script to copy translations into our git repo We want to have the translations as part of our git repo for the following reasons: * developers should build with translations so it is possible to debug translation issues * nightly builds should have translations * a build should not fetch stuff over the network, so we cannot fetch the translations dynamically CCMAIL:kimageshop@kde.org M +0 -1 .gitignore A +6 -0 po/README.md A +55 -0 po/fetch_translations.py https://invent.kde.org/graphics/krita/commit/11364ad8deb4dadac94239a39337dd= 40d91ef22f diff --git a/.gitignore b/.gitignore index 50dd5a3dce..eb77ad3fdc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,5 @@ GRTAGS GSYMS BROWSE *.kate-swp -/po/ build_dir .flatpak-builder diff --git a/po/README.md b/po/README.md new file mode 100644 index 0000000000..61e104de81 --- /dev/null +++ b/po/README.md @@ -0,0 +1,6 @@ +The translations are regularly copied from https://websvn.kde.org. Do +NOT manually commit translations to this folder, but work with the KDE +translation teams from https://l10n.kde.org/. = + +WARNING: any translation committed directly to this folder WILL be = +overwritten the next time we synchronize. diff --git a/po/fetch_translations.py b/po/fetch_translations.py new file mode 100755 index 0000000000..20fa4f0bd8 --- /dev/null +++ b/po/fetch_translations.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 + +stable_url =3D "svn://anonsvn.kde.org/home/kde/branches/stable/l10n-kf5/" +unstable_url =3D "svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5/" +krita_location =3D "messages/krita" + +# determine whether we're in the master branch or not +from git import Repo +repo =3D Repo("..") +print("Current git branch", repo.active_branch) + +if repo.active_branch.name =3D=3D "master": + print("Getting unstable translations") + url =3D unstable_url +else: + print("Getting stable translations") + url =3D stable_url + +print (url); + +# construct the url and get the subdirs file +svn_command =3D url + "subdirs" + +import subprocess +subdirs =3D subprocess.run(["svn", "cat", svn_command], stdout=3Dsubproces= s.PIPE) +for subdir in subdirs.stdout.decode('utf-8').split('\n'): + po_url =3D url + '/' + subdir + '/' + krita_location + "/krita.po" + = + res =3D subprocess.run(["svn", "cat", po_url], stdout=3Dsubprocess.PIP= E, stderr=3Dsubprocess.PIPE) + + po_contents =3D res.stdout.decode('utf-8') + if (len(po_contents) =3D=3D 0): + print ("empty pofile for", subdir, " -- continuing.") + continue + + import os + import shutil + try: + shutil.rmtree(subdir) + except: + pass + = + try: + os.mkdir(subdir) + except: + pass + = + pofile =3D subdir + "/krita.po" + = + print("writing", len(po_contents), "bytes to", pofile) + = + f =3D open(pofile, 'w') + f.write(po_contents) + f.close() + =20