#! /usr/bin/env python3 # -*- coding: utf8 -*- # # Copyright (C) 2018 TMW-2 # Author: Jesusalva import os defaultLang = "en" rootPath = "../../web/" langs=[] files={} originals={} tm=["","\n"] # Populates the basic arrays def populate(): # Populate langs o=open("langs.txt", "r") for i in o: langs.append(i.replace('\n','')) o.close() # Populate files for i in os.listdir(rootPath): if i.endswith(".php.en"): print("Valid file: "+str(i)) files[i]={} for x in langs: files[i][x]={} #print(str(files)) # Creates/Loads stuff def genreadPoFile(): for a in langs: print("Reading translations for "+a) for i in files: readPoFile(i,a) def generatePoFiles(): global tm context=langs context.append('en') for a in langs: print("Updating po file for "+a) xrv=open("po/"+a+".po", "w") # Prints header xrv.write('\ # Copyright (C) 2018 TMW2\n\ #\n\ \n\ msgid ""\n\ msgstr ""\n\ "Project-Id-Version: TMW2\\n"\n\ "MIME-Version: 1.0\\n"\n\ "Content-Type: text/plain; charset=UTF-8\\n"\n\ "Content-Transfer-Encoding: 8bit\\n"\n\ \n\ ') xrv.close() tm=[""] for i in files: writePoFile(i,a) context.remove('en') def generateLocal(): for a in langs: print("generating local file for "+a) for i in files: writeLocal(i,a) # Write po files def writePoFile(nf,lg): # Translation Memory, to prevent duplicates global tm a=open("po/"+lg+".po", "a") f=open(rootPath+nf, "r") for line in f: if line in tm or line.startswith("include ") or line.startswith("") or "