Make moods better translatable.

This commit is contained in:
js 2008-07-29 19:02:57 +00:00
parent 0fae75888a
commit a226760275
4 changed files with 54 additions and 29 deletions

View File

@ -1220,7 +1220,7 @@ class ChatControl(ChatControlBase):
self._mood_image.set_from_pixbuf(gtkgui_helpers.load_mood_icon( self._mood_image.set_from_pixbuf(gtkgui_helpers.load_mood_icon(
mood).get_pixbuf()) mood).get_pixbuf())
# Translate standard moods # Translate standard moods
mood = _(mood.replace('_', ' ')) mood = MOODS[mood]
else: else:
self._mood_image.set_from_pixbuf(gtkgui_helpers.load_mood_icon( self._mood_image.set_from_pixbuf(gtkgui_helpers.load_mood_icon(
'unknown').get_pixbuf()) 'unknown').get_pixbuf())

View File

@ -1,16 +1,37 @@
from common import gajim, xmpp from common import gajim, xmpp
MOODS = ['afraid', 'amazed', 'angry', 'annoyed', 'anxious', 'aroused', MOODS = {
'ashamed', 'bored', 'brave', 'calm', 'cold', 'confused', 'contented', 'afraid': _('Afraid'), 'amazed': _('Amazed'),
'cranky', 'curious', 'depressed', 'disappointed', 'disgusted', 'angry': _('Angry'), 'annoyed': _('Annoyed'),
'distracted', 'embarrassed', 'excited', 'flirtatious', 'frustrated', 'anxious': _('Anxious'), 'aroused': _('Aroused'),
'grumpy', 'guilty', 'happy', 'hot', 'humbled', 'humiliated', 'hungry', 'ashamed': _('Ashamed'), 'bored': _('Bored'),
'hurt', 'impressed', 'in_awe', 'in_love', 'indignant', 'interested', 'brave': _('Brave'), 'calm': _('Calm'),
'intoxicated', 'invincible', 'jealous', 'lonely', 'mean', 'moody', 'cold': _('Cold'), 'confused': _('Confused'),
'nervous', 'neutral', 'offended', 'playful', 'proud', 'relieved', 'contented': _('Contented'), 'cranky': _('Cranky'),
'remorseful', 'restless', 'sad', 'sarcastic', 'serious', 'shocked', 'curious': _('Curious'), 'depressed': _('Depressed'),
'shy', 'sick', 'sleepy', 'stressed', 'surprised', 'thirsty', 'disappointed': _('Disappointed'), 'disgusted': _('Disgusted'),
'thoughtful', 'worried'] 'distracted': _('Distracted'), 'embarrassed': _('Embarassed'),
'excited': _('Excited'), 'flirtatious': _('Flirtatious'),
'frustrated': _('Frustrated'), 'grumpy': _('Grumpy'),
'guilty': _('Guilty'), 'happy': _('Happy'),
'hot': _('Hot'), 'humbled': _('Humbled'),
'humiliated': _('Humiliated'), 'hungry': _('Hungry'),
'hurt': _('Hurt'), 'impressed': _('Impressed'),
'in_awe': _('In Awe'), 'in_love': _('In Love'),
'indignant': _('Indignant'), 'interested': _('Interested'),
'intoxicated': _('Intoxicated'), 'invincible': _('Invincible'),
'jealous': _('Jealous'), 'lonely': _('Lonely'),
'mean': _('Mean'), 'moody': _('Moody'),
'nervous': _('Nervous'), 'neutral': _('Neutral'),
'offended': _('Offended'), 'playful': _('Playful'),
'proud': _('Proud'), 'relieved': _('Relieved'),
'remorseful': _('Remorseful'), 'restless': _('Restless'),
'sad': _('Sad'), 'sarcastic': _('Sarcastic'),
'serious': _('Serious'), 'shocked': _('Shocked'),
'shy': _('Shy'), 'sick': _('Sick'),
'sleepy': _('Sleepy'), 'stressed': _('Stressed'),
'surprised': _('Surprised'), 'thirsty': _('Thirsty'),
'thoughtful': _('Thoughtful'), 'worried': _('Worried')}
# These moods are only available in the Gajim namespace # These moods are only available in the Gajim namespace
GAJIM_MOODS = ['thoughtful'] GAJIM_MOODS = ['thoughtful']

View File

@ -471,19 +471,22 @@ class ChangeMoodDialog:
x = 1 x = 1
y = 0 y = 0
self.mood_buttons = {} self.mood_buttons = {}
# Order them first
self.MOODS = []
for mood in pep.MOODS: for mood in pep.MOODS:
self.mood_buttons[mood] = gtk.RadioButton( self.MOODS.append(mood)
no_mood_button) self.MOODS.sort()
for mood in self.MOODS:
self.mood_buttons[mood] = gtk.RadioButton(no_mood_button)
self.mood_buttons[mood].set_mode(False) self.mood_buttons[mood].set_mode(False)
self.mood_buttons[mood].add( self.mood_buttons[mood].add(gtkgui_helpers.load_mood_icon(mood))
gtkgui_helpers.load_mood_icon(mood))
self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE) self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE)
gtk.Tooltips().set_tip(self.mood_buttons[mood], gtk.Tooltips().set_tip(self.mood_buttons[mood], pep.MOODS[mood])
_(mood.replace('_', ' ')))
self.mood_buttons[mood].connect('clicked', self.mood_buttons[mood].connect('clicked',
self.on_mood_button_clicked, mood) self.on_mood_button_clicked, mood)
table.attach(self.mood_buttons[mood], table.attach(self.mood_buttons[mood], x, x + 1, y, y + 1)
x, x + 1, y, y + 1)
# Calculate the next position # Calculate the next position
x += 1 x += 1
@ -494,11 +497,11 @@ class ChangeMoodDialog:
con = gajim.connections[account] con = gajim.connections[account]
if 'mood' in con.mood: if 'mood' in con.mood:
self.mood = con.mood['mood'] self.mood = con.mood['mood']
self.label.set_text(_( if self.mood in pep.MOODS:
con.mood['mood'].replace('_', ' '))) self.mood_buttons[self.mood].set_active(True)
if con.mood['mood'] in pep.MOODS: self.label.set_text(pep.MOODS[self.mood])
self.mood_buttons[con.mood['mood']]. \ else:
set_active(True) self.label.set_text(self.mood)
if self.mood: if self.mood:
self.entry.set_sensitive(True) self.entry.set_sensitive(True)
@ -513,7 +516,7 @@ class ChangeMoodDialog:
def on_mood_button_clicked(self, widget, data): def on_mood_button_clicked(self, widget, data):
if data: if data:
self.label.set_text(_(data.replace('_', ' '))) self.label.set_text(pep.MOODS[data])
self.entry.set_sensitive(True) self.entry.set_sensitive(True)
else: else:
self.label.set_text(_('None')) self.label.set_text(_('None'))

View File

@ -31,7 +31,7 @@ import gtkgui_helpers
from common import gajim from common import gajim
from common import helpers from common import helpers
from common.pep import ACTIVITIES from common.pep import MOODS, ACTIVITIES
class BaseTooltip: class BaseTooltip:
''' Base Tooltip class; ''' Base Tooltip class;
@ -574,9 +574,10 @@ class RosterTooltip(NotificationAreaTooltip):
''' '''
if contact.mood.has_key('mood'): if contact.mood.has_key('mood'):
mood = contact.mood['mood'].strip() mood = contact.mood['mood'].strip()
if mood in MOODS:
mood = MOODS[mood]
mood = gobject.markup_escape_text(mood) mood = gobject.markup_escape_text(mood)
mood_string = _('Mood:') + ' <b>%s</b>' % \ mood_string = _('Mood:') + ' <b>%s</b>' % mood
_(mood.replace('_', ' '))
if contact.mood.has_key('text') \ if contact.mood.has_key('text') \
and contact.mood['text'] != '': and contact.mood['text'] != '':
mood_text = contact.mood['text'].strip() mood_text = contact.mood['text'].strip()