1#!/usr/bin/env python 2# Copyright (c) 2012 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 9from grit.gather import interface 10from grit import tclib 11 12 13class TxtFile(interface.GathererBase): 14 '''A text file gatherer. Very simple, all text from the file becomes a 15 single clique. 16 ''' 17 18 def Parse(self): 19 self.text_ = self._LoadInputFile() 20 self.clique_ = self.uberclique.MakeClique(tclib.Message(text=self.text_)) 21 22 def GetText(self): 23 '''Returns the text of what is being gathered.''' 24 return self.text_ 25 26 def GetTextualIds(self): 27 return [self.extkey] 28 29 def GetCliques(self): 30 '''Returns the MessageClique objects for all translateable portions.''' 31 return [self.clique_] 32 33 def Translate(self, lang, pseudo_if_not_available=True, 34 skeleton_gatherer=None, fallback_to_english=False): 35 return self.clique_.MessageForLanguage(lang, 36 pseudo_if_not_available, 37 fallback_to_english).GetRealContent() 38