Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openformats/formats/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ def compile(self, template, stringset, is_source=True, language_info=None,

# This is needed in case the first tag is skipped to retain
# the file's formating
first_tag_position = parsed.text_position + len(parsed.text)
parsed_text_length = len(parsed.text) if parsed.text else 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually both parsed.text and text_position are None. Look:

In [41]: parsed.__dict__
Out[41]: 
{'source': '<resources/>\n',
 'start': 0,
 '_position': 0,
 '_tag': 'resources',
 '_attrib': {},
 '_attrib_string': '',
 '_attributes': [],
 '_text_position': None,
 '_text': None,
 '_content_end': openformats.utils.xml.NewDumbXml.NOT_CACHED,
 '_tail_position': 12,
 '_tail': openformats.utils.xml.NewDumbXml.NOT_CACHED}

In [40]: first_tag_position = parsed.text_position + 0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [40], line 1
----> 1 first_tag_position = parsed.text_position + 0

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you see from the above dumped parsed object the template is empty! The resource https://www.transifex.com/careem-1/ridehail-android/translate/#ur/features_ridehail_ui doesn't contain any strings. So I believe we are safe to put it like:

if parsed.text and parsed.text_position:
  first_tag_position = parsed.text_position + len(parsed.text)
  self.transcriber.copy_until(first_tag_position)

The rest of the compile() method code will run without errors...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

first_tag_position = parsed.text_position + parsed_text_length
self.transcriber.copy_until(first_tag_position)

children_iterator = parsed.find_children(
Expand Down