Skip to content Skip to sidebar Skip to footer

Android How To Convert Ios Strings File To Android Xml

I have ios string file that i want to convert into the Android xml file: This is the ios string file which i have want to convert into the Android xml file: /* Localizable.string

Solution 1:

You can take a look at the JavaScript code in the page below, and you could do something similar in Java. It uses regular expressions to parse the input files.

http://members.home.nl/bas.de.reuver/files/stringsconvert.html

Solution 2:

You cannot convert this "programatically" using Android code, because those strings need to be available in your project's resources before compilation, of course.

You could use a simple bash script, like:

echo'<?xml version="1.0" encoding="utf-8"?>'echo'<resources>'whileread line ; do
    tag=$(echo$line | cut -d'"' -f2)
    trad=$(echo$line | cut -d'"' -f4)
    echo"  <string name=\"$tag\">$trad</string>"done < <(cat Localizable.strings | egrep '^".+"\s?=\s?.+$')
echo'</resources>'

That outputs:

<?xml version="1.0" encoding="utf-8"?><resources><stringname="settings_button">Settings</string><stringname="location">Destiny</string><stringname="Register_button">Register</string><stringname="logout">Log Out</string><stringname="login_button">Login</string><stringname="ok">Ok</string><stringname="yes">Yes</string><stringname="no">No</string></resources>

Use it like:

$ bash strings.bash > strings.xml

Note: Everything there is just an example I coded in a minute, adapt as you wish.

Post a Comment for "Android How To Convert Ios Strings File To Android Xml"