diff --git a/scripts/languages/analyze.py b/scripts/languages/analyze.py index 3fa2d628f..acc3f714e 100755 --- a/scripts/languages/analyze.py +++ b/scripts/languages/analyze.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 -import twlang +import os import sys +import twlang + +os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..") if len(sys.argv) > 1: langs = sys.argv[1:] diff --git a/scripts/languages/copy_fix.py b/scripts/languages/copy_fix.py index 8e4f40408..f05e8bf75 100755 --- a/scripts/languages/copy_fix.py +++ b/scripts/languages/copy_fix.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 import twlang +import os import sys +os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..") + if len(sys.argv) < 3: print("usage: python copy_fix.py [--delete-unused] [--append-missing] [--delete-empty]") sys.exit() diff --git a/scripts/languages/find_unchanged.py b/scripts/languages/find_unchanged.py index 561d6f4b9..1f58325eb 100755 --- a/scripts/languages/find_unchanged.py +++ b/scripts/languages/find_unchanged.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 -import twlang +import os import sys +import twlang + +os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/../..") if len(sys.argv) < 2: print("usage: python find_unchanged.py ") diff --git a/scripts/languages/twlang.py b/scripts/languages/twlang.py index 76e766e07..3a3c563ab 100644 --- a/scripts/languages/twlang.py +++ b/scripts/languages/twlang.py @@ -47,20 +47,18 @@ def check_file(path): def check_folder(path): - files = os.listdir(path) englishlist = set() - for f in files: - newpath = os.path.join(path, f) - if os.path.isdir(newpath): - englishlist.update(check_folder(newpath)) - elif os.path.isfile(newpath): - englishlist.update(check_file(newpath)) + for path, _, files in os.walk(path): + for f in files: + if not any(f.endswith(x) for x in ".cpp .c .h".split()): + continue + englishlist.update(check_file(os.path.join(path, f))) return englishlist def languages(): - index = decode(open("../../data/languages/index.txt"), 2) - langs = {"../"+key+".txt" : [key]+elements for key, elements in index.items()} + index = decode(open("data/languages/index.txt"), 2) + langs = {"data/languages/"+key+".txt" : [key]+elements for key, elements in index.items()} return langs @@ -70,5 +68,5 @@ def translations(filename): def localizes(): - englishlist = list(check_folder("../../src")) + englishlist = list(check_folder("src")) return englishlist