Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/po-to-sphinx.py
blob: a994460f0a7fb19be4346895e97ef2b52a337149 (plain)
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
import codecs, os, subprocess

SRC = [
    'index',
    'credits',
    'summary',
    'prolog',
    ]
    
OUT = 'ceibal'

FILE_SEP = '^-^_^-^_^-^_^-^_^-^_^-^_^-^_^-^_'

path_in_po = os.path.join('tmp', '%s-fr.po' % OUT)
path_in_txt = os.path.join('tmp', '%s.txt' % OUT)

subprocess.call('po2txt --encoding utf-8 %s %s' % (path_in_po, path_in_txt),
                shell=True)
                
with codecs.open(path_in_txt, 'rb', 'utf-8') as file_txt:
    for idx, rst in enumerate(file_txt.read().split(FILE_SEP)):
        if idx == len(SRC):
            break
        path_dst = os.path.join('source', 'fr', '%s.rst' % SRC[idx])
        with codecs.open(path_dst, 'wb', 'utf-8') as file_dst:
            file_dst.write(rst.strip())