~ubuntu-branches/ubuntu/quantal/freeguide/quantal

« back to all changes in this revision

Viewing changes to scripts/i18n/generate_REVERSECAPS.py

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2006-09-30 10:14:18 UTC
  • mfrom: (1.2.3 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060930101418-pkilk36yy22nbt3r
Tags: 0.10.4-2
Update the watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python -u
 
2
 
 
3
# Run this script from within its own directory
 
4
 
 
5
import re, os
 
6
 
 
7
en_GB_re = re.compile( "\\.en\\.properties" );
 
8
 
 
9
en_GB_files = []
 
10
en_REVERSECAPS_files = []
 
11
 
 
12
i18n_dir = "../../src/resources/i18n"
 
13
 
 
14
for fl in os.listdir( i18n_dir ):
 
15
        if en_GB_re.search( fl ):
 
16
                en_GB_files.append( file( i18n_dir + "/" + fl, 'r' ) )
 
17
                en_REVERSECAPS_files.append( file( i18n_dir + "/" + fl.replace(
 
18
                        ".en.", ".en_RC." ), 'w' ) )
 
19
 
 
20
for i in range( len( en_GB_files ) ):
 
21
    
 
22
    for line in en_GB_files[i].readlines():
 
23
    
 
24
        split_line = line.split( '=', 1 )
 
25
    
 
26
        if isinstance( split_line, list ) and len( split_line ) == 2:
 
27
            new_line = "%s=%s" % ( split_line[0], split_line[1].swapcase() )
 
28
        elif line[0] == "#":
 
29
            new_line = line
 
30
        else:
 
31
            new_line = line.swapcase()
 
32
        
 
33
        en_REVERSECAPS_files[i].write( new_line )
 
34
        
 
35
    en_REVERSECAPS_files[i].close()
 
36
    en_GB_files[i].close()
 
37