/[gli]/branches/overhaul/src/GLILocalization.py
Gentoo

Contents of /branches/overhaul/src/GLILocalization.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1532 - (show annotations) (download) (as text)
Sun Oct 22 00:08:21 2006 UTC (11 years, 8 months ago) by codeman
File MIME type: text/x-python
File size: 1349 byte(s)
adding a new branch for the overhaul of GLI

1 """
2 # Copyright 1999-2005 Gentoo Foundation
3 # This source code is distributed under the terms of version 2 of the GNU
4 # General Public License as published by the Free Software Foundation, a copy
5 # of which can be found in the main directory of this project.
6 Gentoo Linux Installer
7
8 $Id: GLILocalization.py,v 1.6 2005/08/22 18:35:51 codeman Exp $
9
10 This module is used for reading and returning localized errors and informative
11 messages.
12
13 """
14
15 import codecs
16 import os
17
18 class Localization:
19
20 messages = None
21 lang = None
22
23 ##
24 # Brief description of function
25 # @param self Parameter description
26 # @param filename Parameter description
27 # @param lang=None Parameter description
28 def __init__(self, filename, lang=None):
29 self.messages = {}
30 self.lang = lang or os.getenv("LANG") # maybe LC_ALL
31 message_file = codecs.open(filename, "r", "utf-8")
32 for line in message_file.readlines():
33 line = line.strip()
34 parts = line.split('\t')
35 if not parts[0] in self.messages: self.messages[parts[0]] = {}
36 self.messages[parts[0]][parts[1]] = parts[2]
37
38 ##
39 # Brief description of function
40 # @param self Parameter description
41 # @param message Parameter description
42 def get_localized_message(self, message):
43 if message in self.messages and self.lang in self.messages[message]:
44 return self.messages[message][self.lang]
45 else:
46 return None

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20