stevekchiu / ios-res-tool Goto Github PK
View Code? Open in Web Editor NEWConvert string resources between iOS, Android and CSV
License: MIT License
Convert string resources between iOS, Android and CSV
License: MIT License
Hi. I am trying to use this tool to convert string resources from an existing android project. The very first try resulted in the error described below:
Command executed:
bash-3.2$ ruby ios-res-tool/ios-strings.rb --import-android="/Users/smoky/AndroidstudioProjects/NICEAdminBlue/app/src/main/res" --export-ios=./res
resulted in:
........ (lots of message id's here) string: app_name string: btn_OK string: btn_restting string: info_changeInhibited string: btn_SaveProhibited plurals: upgr_god xml: /Users/smoky/AndroidstudioProjects/NICEAdminBlue/app/src/main/res/values-v11/styles.xml xml: /Users/smoky/AndroidstudioProjects/NICEAdminBlue/app/src/main/res/values-v14/styles.xml xml: /Users/smoky/AndroidstudioProjects/NICEAdminBlue/app/src/main/res/values-v21/styles.xml xml: /Users/smoky/AndroidstudioProjects/NICEAdminBlue/app/src/main/res/values-w820dp/dimens.xml ios-res-tool/ios-strings.rb:408:in
export_ios_string': undefined method gsub!' for nil:NilClass (NoMethodError) from ios-res-tool/ios-strings.rb:425:in
block (2 levels) in export_ios'
from ios-res-tool/ios-strings.rb:423:in each' from ios-res-tool/ios-strings.rb:423:in
block in export_ios'
from ios-res-tool/ios-strings.rb:420:in open' from ios-res-tool/ios-strings.rb:420:in
export_ios'
from ios-res-tool/ios-strings.rb:700:in block (2 levels) in <main>' from ios-res-tool/ios-strings.rb:699:in
each'
from ios-res-tool/ios-strings.rb:699:in block in <main>' from ios-res-tool/ios-strings.rb:694:in
each'
from ios-res-tool/ios-strings.rb:694:in <main>'
The tool looks very promising to me but I do not have knowledge of ruby yet to be able to fix it
Regards, Peter
Hey @SteveKChiu , I was wondering, are you planning to support the new syntax of the language?
Edit: Made a PR #2
String from Android :
<string name="android">
<![CDATA[
<font color="#999999">(%s)</font>
]]>
</string>
After (--export-swift):
"android" = "\n ";
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: jakgra@0df360a 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.