~ubuntu-tour/+junk/new-lang-system

« back to all changes in this revision

Viewing changes to translate.py

  • Committer: Anthony Stewart
  • Date: 2011-04-13 21:04:26 UTC
  • Revision ID: madnessred@gmail.com-20110413210426-x336oab2lh2h2b35
starting with new tour.py system

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import gettext
6
6
import locale
7
7
 
8
 
 
9
 
#Translate function
10
 
__ = gettext.gettext
11
 
 
12
 
 
13
8
#Translate class
14
9
class Translate:
15
10
 
28
23
                gettext.textdomain('ubuntu-tour')
29
24
 
30
25
                #Set locale
31
 
                locale.setlocale(LC_ALL, "")
 
26
                locale.setlocale(locale.LC_ALL, "")
32
27
        
33
28
        
34
29
        #Set translate function
80
75
        
81
76
        
82
77
        #Translate some text
83
 
        def translate(self, string):
 
78
        def translate_string(self, string):
84
79
                
85
80
                #Get strings
86
81
                to_replace = self.get_strings(string)
 
82
                print string
 
83
                print to_replace
87
84
                        
88
85
                #Now for each of the items to be translated
89
86
                for s in to_replace:
90
87
                        s = s.replace("\\(", "(").replace("\\)",")")
91
88
                        string = string.replace("__(" + s + ")", self.translate(s))
92
 
        
 
89
                
93
90
                #Return the string
94
91
                return string
95
92