Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_pot.py « po - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 616443edc4a267b93ff6b1064edfc599a9df72b9 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python

# update the pot file according the POTFILES.in

import os

GETTEXT_XGETTEXT_EXECUTABLE="xgettext"
SOURCE_DIR=".."
DOMAIN="blender"

cmd = "%s --files-from=%s/po/POTFILES.in --keyword=_ --keyword=N_ --directory=%s --output=%s/po/%s.pot --from-code=utf-8" % (
    GETTEXT_XGETTEXT_EXECUTABLE, SOURCE_DIR, SOURCE_DIR, SOURCE_DIR, DOMAIN)

os.system( cmd )

def stripeol(s):
    if line.endswith("\n"):
        s = s[:-1]

    if line.endswith("\r"):
        s = s[:-1]

    return s

pot_messages = {}
reading_message = False
message = ""
with open("blender.pot", 'r') as handle:
    while True:
        line = handle.readline()

        if not line:
            break

        line = stripeol(line)
        if line.startswith("msgid"):
            reading_message = True
            message = line[7:-1]
        elif line.startswith("msgstr"):
            reading_message = False
            pot_messages[message] = True
        elif reading_message:
            message += line[1:-1]

# add messages collected automatically from RNA
with open("blender.pot", "a") as pot_handle:
    with open("messages.txt", 'r') as handle:
        while True:
            line = handle.readline()

            if not line:
                break

            line = stripeol(line)
            line = line.replace("\\", "\\\\")
            line = line.replace("\"", "\\\"")

            if not pot_messages.get(line):
                pot_handle.write("\n#: Automatically collected from RNA\n")
                pot_handle.write("msgid \"%s\"\n" % (line))
                pot_handle.write("msgstr \"\"\n")