Simplify your developer life with Boop

Manuel Kunz
StepUp Development
Published in
2 min readAug 30, 2020
"main_hero_name" = "Hercules";
<string name="main_hero_name">Hercules</string>

If you have ever seen this, you are probably an app developer, you have at least developed for Android and iOS and at some point you dealt with assets like localizables.

Keeping your iOS and Android localizables in sync can be hard, especially when you work in a team and your project grows. Your localizables end up being different on both platforms and it just keeps getting harder to maintain. It would be simple if you could just copy and paste those strings from one platform to the other and you could be sure that every key and value is the same. One way to do this is to use tools other people have already written for us. One of these tools is Boop.

You can use Boop for your daily routine of developing, e.g. format and validate your JSON file, decode and encode data, count words, sort lines and so much more. With Boop you can use one offline tool instead of 5 online tools you have to keep switching between to get your results. The best part is, you can add custom scripts easily.

For the Localizable handling between iOS and Android you could use two simple scripts to convert Android to iOS Localizables and conversely.

Android to iOS

/**
{
"api":1,
"name":"Android Strings to iOS Localizables",
"description":"Converts Android Strings to iOS Localizables",
"author":"Manuel Kunz",
"icon":"quote",
"tags":"string, android, ios"
}
**/

function main(input) {
let lines = input.fullText.split('\n')
var result = []
lines.forEach(element => {
var temp = element
temp = temp.replace("<string name=", "")
temp = temp.replace("</string>", "\";")
temp = temp.replace(">", " = \"")
result.push(temp)
})

input.fullText = result.join('\n')
}

iOS to Android

/**
{
"api":1,
"name":"iOS Localizables to Android Strings",
"description":"Converts iOS Localizables to Android Strings",
"author":"Manuel Kunz",
"icon":"quote",
"tags":"string, android, ios"
}
**/

function main(input) {
let lines = input.fullText.split('\n')
var result = []
lines.forEach(element => {
if(element !== "") {
var regex = /"(.*?)"/g
var matches = [];
var match = regex.exec(element);
while (match != null) {
matches.push(match[1]);
match = regex.exec(element);
}
result.push("<string name=\"" + matches[0] + "\">" + matches[1] + "</string>")
}
})
input.fullText = result.join('\n')
}

Tools like this just help you get your work done in one place and make your developer life easier. If you have any ideas of scripts you could imagine to write and include to Boop, feel free to share your ideas. We would like to hear from you.

--

--