in library/scripts/string_pack.py [0:0]
def build(input_file_names, output_file_name, id_finder, plural_handler):
"""Builds the string pack and writes it to a file.
It tries both UTF-8 and UTF-16 to see which one is smaller, and then writes
the string pack in that encoding."""
packs = []
for encoding in _ENCODING_ID.keys():
full_store = StringPack(encoding=encoding)
for input_file_name in input_file_names:
locale = extract_locale_from_file_name(input_file_name)
full_store.add_for_locale(
locale,
read_string_dict(locale, input_file_name, id_finder, plural_handler),
)
full_store.compile()
packs.append(full_store)
smallest_pack = min(packs, key=lambda p: p.string_buffer_size())
smallest_pack.write_to_file(output_file_name)