1

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.strings
 SaiÌda da Escola

 Created by farhan shah on 11/12/2013.
 Copyright (c) 2013 whizpool. All rights reserved.
 */

"settings_button" = "Settings";

"location" = "Destiny";

"Register_button" = "Register";

"logout" = "Log Out";

"login_button" = "Login";

"ok" = "Ok";

"yes" = "Yes";

"no" = "No";

the result should be like this like Android xml file:

<?xml version="1.0" encoding="utf-8"?>
 <resources>
<!--
 Localizable.strings
 SaiÌda da Escola

 Created by farhan shah on 11/12/2013.
 Copyright (c) 2013 whizpool. All rights reserved.
 -->

<string name="settings_button">Settings</string>

<string name="location">Destiny</string>

<string name="register_button">Register</string>

<string name="logout">Log Out</string>

<string name="login_button">Login</string>

<string name="ok">Ok</string>

<string name="yes">Yes</string>

<string name="no">No</string>


</resources>

any help,idea and sample code will be highly appreciated,Thanks alot in advance.

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

As a more modern alternative, I would recommend "attranslate": github.com/fkirc/attranslate
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>'
while read 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>
  <string name="settings_button">Settings</string>
  <string name="location">Destiny</string>
  <string name="Register_button">Register</string>
  <string name="logout">Log Out</string>
  <string name="login_button">Login</string>
  <string name="ok">Ok</string>
  <string name="yes">Yes</string>
  <string name="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.

5 Comments

kindely can u explain it more?i did't understand that how i can achieve this.and also snippet code in android might help alot thnaks.
@FarhanShah this is a bash script, no Android code.
@FarhanShah bro, not possible. Read updated answer and learn how to use a shell.
and tell me this is possible in android?
@FarhanShah Just read, quote: "You cannot convert this "programatically" using Android code, because those strings need to be available in your project's resources before compilation, of course."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.