ios-res-tool icon indicating copy to clipboard operation
ios-res-tool copied to clipboard

Styled android text doesn't work

Open jakgra opened this issue 5 years ago • 1 comments

First of all thanks for the great scripts. It's really simple to use them :).

When using the ios-strings.rb script in our project I encountered issues with strings that included styling with html tags. Only the first element/text element was included in the ios string after the import from android.

Example of a problematic string: <string name="nicebox">Nice<b>box</b></string>. In android I use it via ui_widget.setText(getText(R.string.nicebox)) and it correctly sets the text but on ios when I use it via some_function_to_parse_html(R.string.nicebox^) the output is just Nice the <b>box</b> part gets completely ignored.

I fixed the script so it works for our project here: https://github.com/jakgra/ios-res-tool/commit/0df360aa80ae8d03760a107ab10641b94e3dffd6 and can create a pull request if you want ?, but I'm not sure it doesn't break some other use case.

The android documentation describing styled strings embeded in strings.xml files: https://developer.android.com/guide/topics/resources/string-resource.html#StylingWithHTML https://developer.android.com/reference/android/content/Context.html#getText(int) and some examples of usage: https://stackoverflow.com/questions/45647928/what-is-the-difference-between-getstring-and-gettext

jakgra avatar Oct 16 '19 09:10 jakgra

Yes, pull request is welcome.

SteveKChiu avatar Jan 31 '20 03:01 SteveKChiu