Index: chrome/installer/util/prebuild/create_string_rc.py |
diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py |
index ce885e05e62af97777314397c79d1f05aa0dc36a..ec654661d5a5198ee16ff3c57fc7d589a8fe48bd 100755 |
--- a/chrome/installer/util/prebuild/create_string_rc.py |
+++ b/chrome/installer/util/prebuild/create_string_rc.py |
@@ -44,12 +44,15 @@ |
from grit.extern import tclib |
# The IDs of strings we want to import from the .grd files and include in |
-# setup.exe's resources. These strings are universal for all brands. |
+# setup.exe's resources. |
STRING_IDS = [ |
'IDS_ABOUT_VERSION_COMPANY_NAME', |
'IDS_APP_SHORTCUTS_SUBDIR_NAME', |
+ 'IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY', |
'IDS_INBOUND_MDNS_RULE_DESCRIPTION', |
+ 'IDS_INBOUND_MDNS_RULE_DESCRIPTION_CANARY', |
'IDS_INBOUND_MDNS_RULE_NAME', |
+ 'IDS_INBOUND_MDNS_RULE_NAME_CANARY', |
'IDS_INSTALL_EXISTING_VERSION_LAUNCHED', |
'IDS_INSTALL_FAILED', |
'IDS_INSTALL_HIGHER_VERSION', |
@@ -66,6 +69,7 @@ |
'IDS_SETUP_PATCH_FAILED', |
'IDS_SHORTCUT_NEW_WINDOW', |
'IDS_SHORTCUT_TOOLTIP', |
+ 'IDS_SXS_SHORTCUT_NAME', |
] |
# Certain strings are conditional on a brand's install mode (see |
@@ -102,8 +106,6 @@ |
'IDS_APP_SHORTCUTS_SUBDIR_NAME': { |
'google_chrome': [ |
'IDS_APP_SHORTCUTS_SUBDIR_NAME', |
- 'IDS_APP_SHORTCUTS_SUBDIR_NAME_BETA', |
- 'IDS_APP_SHORTCUTS_SUBDIR_NAME_DEV', |
'IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY', |
], |
'chromium': [ |
@@ -113,8 +115,6 @@ |
'IDS_INBOUND_MDNS_RULE_DESCRIPTION': { |
'google_chrome': [ |
'IDS_INBOUND_MDNS_RULE_DESCRIPTION', |
- 'IDS_INBOUND_MDNS_RULE_DESCRIPTION_BETA', |
- 'IDS_INBOUND_MDNS_RULE_DESCRIPTION_DEV', |
'IDS_INBOUND_MDNS_RULE_DESCRIPTION_CANARY', |
], |
'chromium': [ |
@@ -124,8 +124,6 @@ |
'IDS_INBOUND_MDNS_RULE_NAME': { |
'google_chrome': [ |
'IDS_INBOUND_MDNS_RULE_NAME', |
- 'IDS_INBOUND_MDNS_RULE_NAME_BETA', |
- 'IDS_INBOUND_MDNS_RULE_NAME_DEV', |
'IDS_INBOUND_MDNS_RULE_NAME_CANARY', |
], |
'chromium': [ |
@@ -139,8 +137,6 @@ |
'IDS_PRODUCT_NAME': { |
'google_chrome': [ |
'IDS_PRODUCT_NAME', |
- 'IDS_SHORTCUT_NAME_BETA', |
- 'IDS_SHORTCUT_NAME_DEV', |
'IDS_SXS_SHORTCUT_NAME', |
], |
'chromium': [ |
@@ -161,17 +157,17 @@ |
Attributes: |
messages: A dict mapping string identifiers to their corresponding messages. |
""" |
- def __init__(self, string_id_set): |
+ def __init__(self, string_ids): |
"""Constructs a handler that reads selected strings from a .grd file. |
The dict attribute |messages| is populated with the strings that are read. |
Args: |
- string_id_set: A set of message identifiers to extract. |
+ string_ids: A list of message identifiers to extract. |
""" |
sax.handler.ContentHandler.__init__(self) |
self.messages = {} |
- self.__id_set = string_id_set |
+ self.__id_set = set(string_ids) |
self.__message_name = None |
self.__element_stack = [] |
self.__text_scraps = [] |
@@ -310,10 +306,9 @@ |
self.brand = brand |
def MakeFiles(self): |
- string_id_set = self.__BuildStringIds() |
- translated_strings = self.__ReadSourceAndTranslatedStrings(string_id_set) |
+ translated_strings = self.__ReadSourceAndTranslatedStrings() |
self.__WriteRCFile(translated_strings) |
- self.__WriteHeaderFile(string_id_set, translated_strings) |
+ self.__WriteHeaderFile(translated_strings) |
class __TranslationData(object): |
"""A container of information about a single translation.""" |
@@ -327,21 +322,7 @@ |
id_result = cmp(self.resource_id_str, other.resource_id_str) |
return cmp(self.language, other.language) if id_result == 0 else id_result |
- def __BuildStringIds(self): |
- """Returns the set of string IDs to extract from the grd and xtb files.""" |
- # Start with the strings that apply to all brands. |
- string_id_set = set(STRING_IDS) |
- # Add in the strings for the current brand. |
- for string_id, brands in MODE_SPECIFIC_STRINGS.iteritems(): |
- brand_strings = brands.get(self.brand) |
- if not brand_strings: |
- raise exceptions.RuntimeError( |
- 'No strings declared for brand \'%s\' in MODE_SPECIFIC_STRINGS for ' |
- 'message %s' % (self.brand, string_id)) |
- string_id_set.update(brand_strings) |
- return string_id_set |
- |
- def __ReadSourceAndTranslatedStrings(self, string_id_set): |
+ def __ReadSourceAndTranslatedStrings(self): |
"""Reads the source strings and translations from all inputs.""" |
translated_strings = [] |
for grd_file, xtb_dir in self.inputs: |
@@ -351,20 +332,18 @@ |
xtb_pattern = os.path.join(os.path.dirname(grd_file), xtb_dir, |
'%s*.xtb' % source_name) |
translated_strings.extend( |
- self.__ReadSourceAndTranslationsFrom(string_id_set, grd_file, |
- glob.glob(xtb_pattern))) |
+ self.__ReadSourceAndTranslationsFrom(grd_file, glob.glob(xtb_pattern))) |
translated_strings.sort() |
return translated_strings |
- def __ReadSourceAndTranslationsFrom(self, string_id_set, grd_file, xtb_files): |
+ def __ReadSourceAndTranslationsFrom(self, grd_file, xtb_files): |
"""Reads source strings and translations for a .grd file. |
Reads the source strings and all available translations for the messages |
- identified by string_id_set. The source string is used where translations |
- are missing. |
+ identified by STRING_IDS. The source string is used where translations are |
+ missing. |
Args: |
- string_id_set: The identifiers of the strings to read. |
grd_file: Path to a .grd file. |
xtb_files: List of paths to .xtb files. |
@@ -374,7 +353,7 @@ |
sax_parser = sax.make_parser() |
# Read the source (en-US) string from the .grd file. |
- grd_handler = GrdHandler(string_id_set) |
+ grd_handler = GrdHandler(STRING_IDS) |
sax_parser.setContentHandler(grd_handler) |
sax_parser.parse(grd_file) |
source_strings = grd_handler.messages |
@@ -438,7 +417,7 @@ |
escaped_text)) |
outfile.write(FOOTER_TEXT) |
- def __WriteHeaderFile(self, string_id_set, translated_strings): |
+ def __WriteHeaderFile(self, translated_strings): |
"""Writes a .h file with resource ids.""" |
# TODO(grt): Stream the lines to the file rather than building this giant |
# list of lines first. |
@@ -482,7 +461,7 @@ |
% (string_id, ', '.join([ ('%s_BASE' % s) for s in brand_strings]))) |
# Write out base ID values. |
- for string_id in sorted(string_id_set): |
+ for string_id in STRING_IDS: |
lines.append('#define %s_BASE %s_%s' % (string_id, |
string_id, |
translated_strings[0].language)) |