summaryrefslogblamecommitdiff
path: root/web/legacy
blob: 4629a063100e430138e211a58a68272944b1103e (plain) (tree)


















































                                                                     
#! /usr/bin/env python2.7
# -*- coding: utf8 -*-
#
# Copyright (C) 2018  TMW-2
# Author: Jesusalva

import os
import re

defaultLang = "en"

rootPath = "../../web/"

filt = re.compile(".+[.]php", re.IGNORECASE)

allFiles=[]
langFiles = dict()
langs = []       # Current languages

# Read languages
o=open("langs.txt", "r")
for i in o:
    langs.append(i.replace('\n',''))
o.close()

# Read PHP files, and create langFiles[i]["master"]
for i in os.listdir(rootPath):
    if i.endswith(".php"):
        langFiles[i]={}
        o=open(rootPath+'/'+i, 'r')
        for line in o:
            langFiles[i]["master"]=line
        o.close()

# Sort each language for stuff
for a in langFiles:
    for b in langs:
        langFiles[a][b]=[]

        cnt=0
        pot=open("po/"+b+".po", "r")
        for line in pot:
            if "msgstr" in line:
                abaco=str(line.replace('msgstr "','')[:-1])
                if abaco != "":
                    langFiles[a][b].append(abaco)
                else:
                    langFiles[a][b].append(langFiles[a][master][cnt])
                cnt+=1

        print str(langFiles[a][b])