/[gli]/trunk/src/GLISayWhat.py
Gentoo

Contents of /trunk/src/GLISayWhat.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations) (download) (as text)
Fri Feb 18 07:15:01 2005 UTC (13 years, 9 months ago) by agaffney
File MIME type: text/x-python
File size: 841 byte(s)
created GLISayWhat module

1 """
2 Gentoo Linux Installer
3
4 $Id: GLISayWhat.py,v 1.1 2005/02/18 07:15:01 agaffney Exp $
5 Copyright 2004 Gentoo Technologies Inc.
6
7
8 This module is used for reading and returning localized errors and informative
9 messages.
10
11 """
12
13 import codecs
14 import os
15
16 class SayWhat:
17
18 messages = None
19
20 def __init__(self, filename):
21 self.messages = {}
22 file = codecs.open(filename, "r", "utf-8")
23 for line in file.readlines():
24 parts = line.split('\t')
25 if not parts[0] in self.messages: self.messages[parts[0]] = {}
26 self.messages[parts[0]][parts[1]] = parts[2]
27
28 def get_localized_message(self, message, lang=None):
29 localized_message = None
30
31 if not lang:
32 lang = os.getenv("LANG") # maybe LC_ALL
33 if message in self.messages and lang in self.messages[message]:
34 localized_message = self.messages[message][lang]
35 return localized_message

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20