SteveKChiu / ios-res-tool

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

undefined method `gsub!' when trying to convert #3

Open dilmash opened 7 years ago

dilmash commented 7 years ago

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:inexport_ios_string': undefined method gsub!' for nil:NilClass (NoMethodError) from ios-res-tool/ios-strings.rb:425:inblock (2 levels) in export_ios' from ios-res-tool/ios-strings.rb:423:in each' from ios-res-tool/ios-strings.rb:423:inblock in export_ios' from ios-res-tool/ios-strings.rb:420:in open' from ios-res-tool/ios-strings.rb:420:inexport_ios' from ios-res-tool/ios-strings.rb:700:in block (2 levels) in <main>' from ios-res-tool/ios-strings.rb:699:ineach' from ios-res-tool/ios-strings.rb:699:in block in <main>' from ios-res-tool/ios-strings.rb:694:ineach' 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

SteveKChiu commented 7 years ago

Hopefully the commit would fix the problem.

dilmash commented 7 years ago

Having checked with updated ios-strings.rb but similar result:

ios-res-tool/ios-strings.rb:410:in `export_ios_string': undefined method `gsub!' for nil:NilClass (NoMethodError)
    from ios-res-tool/ios-strings.rb:427:in `block (2 levels) in export_ios'
    from ios-res-tool/ios-strings.rb:425:in `each'
    from ios-res-tool/ios-strings.rb:425:in `block in export_ios'
    from ios-res-tool/ios-strings.rb:422:in `open'
    from ios-res-tool/ios-strings.rb:422:in `export_ios'
    from ios-res-tool/ios-strings.rb:702:in `block (2 levels) in <main>'
    from ios-res-tool/ios-strings.rb:701:in `each'
    from ios-res-tool/ios-strings.rb:701:in `block in <main>'
    from ios-res-tool/ios-strings.rb:696:in `each'
    from ios-res-tool/ios-strings.rb:696:in `<main>'

There are 12 language files with 244 strings each. The error occurs after all file names have been listed.

SteveKChiu commented 7 years ago

Hi,

Is it possible to send me a copy of the resource files for testing?

It would be a lot faster for me to identify the issues.

Thanks, Steve

dilmash notifications@github.com 於 2017年4月7日 下午8:40 寫道:

Having checked with updated ios-strings.rb but similar result:

ios-res-tool/ios-strings.rb:410:in export_ios_string': undefined methodgsub!' for nil:NilClass (NoMethodError) from ios-res-tool/ios-strings.rb:427:in block (2 levels) in export_ios' from ios-res-tool/ios-strings.rb:425:ineach' from ios-res-tool/ios-strings.rb:425:in block in export_ios' from ios-res-tool/ios-strings.rb:422:inopen' from ios-res-tool/ios-strings.rb:422:in export_ios' from ios-res-tool/ios-strings.rb:702:inblock (2 levels) in

' from ios-res-tool/ios-strings.rb:701:in each' from ios-res-tool/ios-strings.rb:701:inblock in
' from ios-res-tool/ios-strings.rb:696:in each' from ios-res-tool/ios-strings.rb:696:in
'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dilmash commented 7 years ago

Steve, I managed to find the possible cause of this issue. I doe have an empty string in my resources that causes the reported problem. One can circumvent it by ignoring empty strings but that does not help much. In addition, any string marked with translatable="false" is not converted as well, that hurts me a lot more. Is there a chance that you update this genius little script to handle null strings and translatable="false" ? Regards, Peter