From ef8e07c5c3ae4738d249b318b41e71df91887d29 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Tue, 3 Mar 2009 18:28:18 +0000 Subject: Use grit to generate locale rc files and remove the old locale rc files from the tree. I made a small change to grit so we can use our resource ID as the translation ID making it a bit easier to read. I also used a script to convert the existing .rc files to .xtb files. Review URL: http://codereview.chromium.org/28327 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10809 0039d316-1c4b-4281-b951-d872f2087c98 --- tools/grit/grit/node/message.py | 11 ++++++++--- tools/grit/grit/tclib.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/grit/grit/node/message.py b/tools/grit/grit/node/message.py index 449238b..7086538 100644 --- a/tools/grit/grit/node/message.py +++ b/tools/grit/grit/node/message.py @@ -54,7 +54,7 @@ class MessageNode(base.ContentNode): def _IsValidAttribute(self, name, value): if name not in ['name', 'offset', 'translateable', 'desc', 'meaning', 'internal_comment', 'shortcut_groups', 'custom_type', - 'validation_expr']: + 'validation_expr', 'use_name_for_id']: return False if name == 'translateable' and value not in ['true', 'false']: return False @@ -72,6 +72,7 @@ class MessageNode(base.ContentNode): 'shortcut_groups' : '', 'custom_type' : '', 'validation_expr' : '', + 'use_name_for_id' : 'false', } def GetTextualIds(self): @@ -139,10 +140,14 @@ class MessageNode(base.ContentNode): description_or_id = self.attrs['desc'] if description_or_id == '' and 'name' in self.attrs: description_or_id = 'ID: %s' % self.attrs['name'] - + + assigned_id = None + if self.attrs['use_name_for_id'] == 'true': + assigned_id = self.attrs['name'] message = tclib.Message(text=text, placeholders=placeholders, description=description_or_id, - meaning=self.attrs['meaning']) + meaning=self.attrs['meaning'], + assigned_id=assigned_id) self.clique = self.UberClique().MakeClique(message, self.IsTranslateable()) for group in self.shortcut_groups_: self.clique.AddToShortcutGroup(group) diff --git a/tools/grit/grit/tclib.py b/tools/grit/grit/tclib.py index 846ce15..d97d675 100644 --- a/tools/grit/grit/tclib.py +++ b/tools/grit/grit/tclib.py @@ -144,14 +144,24 @@ class BaseMessage(object): class Message(BaseMessage): '''A message.''' - def __init__(self, text='', placeholders=[], description='', meaning=''): + def __init__(self, text='', placeholders=[], description='', meaning='', + assigned_id=None): BaseMessage.__init__(self, text, placeholders, description, meaning) + self.assigned_id = assigned_id def ToTclibMessage(self): msg = grit.extern.tclib.Message('utf-8', meaning=self.meaning) self.FillTclibBaseMessage(msg) return msg + def GetId(self): + '''Use the assigned id if we have one.''' + if self.assigned_id: + return self.assigned_id + + return BaseMessage.GetId(self) + + class Translation(BaseMessage): '''A translation.''' -- cgit v1.1