summaryrefslogtreecommitdiff
path: root/web/legacy
blob: 4629a063100e430138e211a58a68272944b1103e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /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])