in library/scripts/string_pack.py [0:0]
def get_binary_blob(self):
blob = bytearray()
blob_append_16_bit(blob, len(self.strings))
blob_append_16_bit(blob, len(self.plurals))
# Write the strings. Note that the parser in ParsedStringPack.java expects this to be
# sorted by ID.
# However the ids are already entered in sorted manner. So no need to re-sort them
for id in self.strings:
blob_append_16_bit(blob, id)
start, length = self.strings[id]
blob_append_32_bit(blob, start)
blob_append_16_bit(blob, length)
# Write the plurals
for id in self.plurals:
blob_append_16_bit(blob, id)
plural = self.plurals[id]
blob.append(len(plural)) # Just one byte
for quantity_id in sorted(plural):
blob.append(quantity_id) # Just one byte
start, length = plural[quantity_id]
blob_append_32_bit(blob, start)
blob_append_16_bit(blob, length)
return bytes(blob)