Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: grit/gather/txt.py

Issue 7994004: Initial source commit to grit-i18n project. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/gather/tr_html_unittest.py ('k') | grit/gather/txt_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 '''Supports making amessage from a text file.
7 '''
8
9 import types
10
11 from grit.gather import interface
12 from grit import tclib
13 from grit import util
14
15
16 class TxtFile(interface.GathererBase):
17 '''A text file gatherer. Very simple, all text from the file becomes a
18 single clique.
19 '''
20
21 def __init__(self, contents):
22 super(type(self), self).__init__()
23 self.text_ = contents
24 self.clique_ = None
25
26 def Parse(self):
27 self.clique_ = self.uberclique.MakeClique(tclib.Message(text=self.text_))
28 pass
29
30 def GetText(self):
31 '''Returns the text of what is being gathered.'''
32 return self.text_
33
34 def GetTextualIds(self):
35 return []
36
37 def GetCliques(self):
38 '''Returns the MessageClique objects for all translateable portions.'''
39 return [self.clique_]
40
41 def Translate(self, lang, pseudo_if_not_available=True,
42 skeleton_gatherer=None, fallback_to_english=False):
43 return self.clique_.MessageForLanguage(lang,
44 pseudo_if_not_available,
45 fallback_to_english).GetRealContent()
46
47 def FromFile(filename_or_stream, extkey=None, encoding = 'cp1252'):
48 if isinstance(filename_or_stream, types.StringTypes):
49 filename_or_stream = util.WrapInputStream(file(filename_or_stream, 'rb'), encoding)
50 return TxtFile(filename_or_stream.read())
51 FromFile = staticmethod(FromFile)
52
OLDNEW
« no previous file with comments | « grit/gather/tr_html_unittest.py ('k') | grit/gather/txt_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698