SteveKChiu / ios-res-tool

Convert string resources between iOS, Android and CSV
MIT License
24 stars 10 forks source link

Styled android text doesn't work #7

Open jakgra opened 5 years ago

jakgra commented 5 years ago

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

SteveKChiu commented 4 years ago

Yes, pull request is welcome.