[graphics/krita/rempt/copy_po_files] /: Add a script to copy translations into our git repo

Boudewijn Rempt null at kde.org
Thu Oct 15 10:56:26 BST 2020


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 at 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/11364ad8deb4dadac94239a39337dd40d91ef22f

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 = "svn://anonsvn.kde.org/home/kde/branches/stable/l10n-kf5/"
+unstable_url = "svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5/"
+krita_location = "messages/krita"
+
+# determine whether we're in the master branch or not
+from git import Repo
+repo = Repo("..")
+print("Current git branch", repo.active_branch)
+
+if repo.active_branch.name == "master":
+    print("Getting unstable translations")
+    url = unstable_url
+else:
+    print("Getting stable translations")
+    url = stable_url
+
+print (url);
+
+# construct the url and get the subdirs file
+svn_command = url + "subdirs"
+
+import subprocess
+subdirs = subprocess.run(["svn", "cat", svn_command], stdout=subprocess.PIPE)
+for subdir in subdirs.stdout.decode('utf-8').split('\n'):
+    po_url = url + '/' + subdir + '/' + krita_location + "/krita.po"
+    
+    res = subprocess.run(["svn", "cat", po_url], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    po_contents = res.stdout.decode('utf-8')
+    if (len(po_contents) == 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 = subdir + "/krita.po"
+    
+    print("writing", len(po_contents), "bytes to", pofile)
+        
+    f = open(pofile, 'w')
+    f.write(po_contents)
+    f.close()
+    


More information about the kimageshop mailing list