~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to language/update.py

  • Committer: z-man
  • Date: 2009-01-14 12:00:51 UTC
  • mto: (563.26.1 0.2.8-armagetronad-sync) (661.1.1 0.2.8-armagetronad-sty+ct)
  • mto: This revision was merged to the branch mainline in revision 657.
  • Revision ID: svn-v3-list-QlpoOTFBWSZTWZvbKhsAAAdRgAAQABK6798QIABURMgAAaeoNT1TxT1DQbKaeobXKiyAmlWT7Y5MkdJOtXDtB7w7DOGFBHiOBxaUIu7HQyyQSvxdyRThQkJvbKhs:7d95bf1e-0414-0410-9756-b78462a59f44:armagetronad%2Fbranches%2F0.2.8%2Farmagetronad:8820
Turned down optimization level. Seems to solve the crash issue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#           panish translation is up to date.
10
10
#           the --complete switch adds the original texts as comments to all items, even
11
11
#           those already translated.
12
 
#           the --scm switch removes all comments added by previous runs so you can
13
 
#           easily check in partial translations into source control.
14
12
#
15
13
# update.py --dist
16
14
#           compactifies translations: strips comments and whitespace
24
22
    def __init__(self):
25
23
        # maximal assumed length of identifier
26
24
        self.maxlen = 30
27
 
        self.commentAll  = False
28
 
        self.commentNone = False
 
25
        self.commentAll = False
29
26
        self.autoComment = "#ORIGINAL TEXT:"
30
27
        self.autoComment2 = "#TRANSLATION "
31
28
        self.untranslated = "UNTRANSLATED\n"
56
53
            del self.dictionary[ key ]
57
54
        except KeyError:
58
55
            # translation not found: note that.
59
 
            if not self.commentNone:
60
 
                self.Write( "#" + key, self.untranslated )
 
56
            self.Write( "#" + key, self.untranslated )
61
57
 
62
58
    # writes dictionary to open outfile
63
59
    def WriteDictionary0( self ):
120
116
        # flag indicating whether the next item needs an extra separation line
121
117
        separate = True    
122
118
 
123
 
        # flag indicating whether the last language item was translated
124
 
        lastTranslated = True
125
 
 
126
 
        # flag indicating whether the last line was empty
127
 
        lastEmpty = False
128
 
 
129
119
        # read through base file, rewriting it
130
120
        for line in infile.readlines():
131
121
            pair = self.ParseLine( line )
134
124
                try: del self.lostcomments[ line ]
135
125
                except KeyError: pass
136
126
                # just print line, it is a comment or whitespace
137
 
                empty = ( len(line) <= 1 )
138
 
                if lastTranslated or ( not empty or not lastEmpty ):
139
 
                    self.outfile.write( line )
140
 
                    lastEmpty = empty
 
127
                self.outfile.write( line )
141
128
                separate = False
142
129
            else:
143
130
                if not pair[0] == "include":
144
131
                    # write original text as a comment
145
 
                    lastTranslated = pair[0] in self.dictionary
146
 
                    if self.commentAll or ( not lastTranslated and not self.commentNone ):
 
132
                    if self.commentAll or pair[0] not in self.dictionary:
147
133
                        if separate:
148
134
                            self.outfile.write("\n")
149
135
                        self.Write( self.autoComment, pair[1] )
200
186
 
201
187
if __name__ == "__main__":
202
188
    # determine languages to update: everything included from
203
 
    # languages.txt.in except am/eng and custom.
 
189
    # languages.txt.in except am/eng.
204
190
    files = []
205
191
    listfile = open("languages.txt.in")
206
192
    for line in listfile.readlines():
207
193
        if line.startswith("include"):
208
194
            file =line.split()[1]
209
 
            if file != "american.txt" and file != "english.txt" and file != "british.txt" and file != "custom.txt":
 
195
            if file != "american.txt" and file != "english.txt" and file != "british.txt":
210
196
                files += [file]
211
197
 
212
198
    lu = LanguageUpdater()
218
204
    else:
219
205
        if len( sys.argv ) >= 2 and sys.argv[1] == "--complete":
220
206
            lu.commentAll = True
221
 
        if len( sys.argv ) >= 2 and sys.argv[1] == "--scm":
222
 
            lu.commentNone = True
223
207
 
224
208
        # read in all translations
225
209
        for file in sys.argv[1:]: