Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/sphinx-to-po.py
blob: 2781360accc22f30c72032ab343be96ee5e104cf (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import codecs, os, subprocess

SRC = [
    'index',
    'credits',
    'prolog',
    'intro',
    'section_1',
    'chapter_1',
    'chapter_2',
    'chapter_3',
    'chapter_4',
    'chapter_5',
    'chapter_6',
    'chapter_7',
    'chapter_8',
    'section_2',
    'chapter_9',
    'chapter_10',
    'chapter_11',
    'chapter_12',
    'annex',
    'credits_photo',
    ]
    
OUT = 'ceibal'

FILE_SEP = '\n\n\n^-^_^-^_^-^_^-^_^-^_^-^_^-^_^-^_\n\n\n'

path_out_txt = os.path.join('tmp', '%s.txt' % OUT)
with codecs.open(path_out_txt, 'wb', 'utf-8') as file_po:
    for name in SRC:
        path_src = os.path.join('source', 'es', '%s.rst' % name)
        with codecs.open(path_src, 'rb', 'utf-8') as file_src:
            file_po.write(file_src.read())
            file_po.write(FILE_SEP)

path_out_po = os.path.join('tmp', '%s.po' % OUT)
subprocess.call('txt2po --encoding utf-8 %s %s' % (path_out_txt, path_out_po),
                shell=True)