I had the same issue in Android Studio, i didn't have access to copy all the entries from the Translation Editor, so i decided to do my own XmlResourceParser which reads all the keys and values from a specific strings.xml file. Of course, you can use and modify this script according to your needs.
private void parseResourceXML(XmlResourceParser parser) {
try
{
int eventType = parser.getEventType();
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
StringBuilder sbValues = new StringBuilder();
StringBuilder sbKeys = new StringBuilder();
String nameAttr = "";
boolean translatableAttr = true;
while (eventType != XmlResourceParser.END_DOCUMENT)
{
if (eventType == XmlResourceParser.START_DOCUMENT)
{
//Log.d("XmlResourceParser", "Start Document");
}
else if (eventType == XmlResourceParser.START_TAG)
{
//Log.d("XmlResourceParser", "Start Tag " + parser.getName());
String element = parser.getName();
if (!TextUtils.isEmpty(element))
{
switch (element)
{
case "string":
nameAttr = parser.getAttributeValue(null, "name");
translatableAttr = parser.getAttributeBooleanValue(null, "translatable", true);
map.put(nameAttr, nameAttr);
sbKeys.append(nameAttr);
sbKeys.append("\n");
break;
case "string-array":
nameAttr = parser.getAttributeValue(null, "name");
translatableAttr = parser.getAttributeBooleanValue(null, "translatable", true);
break;
case "item":
nameAttr = parser.getAttributeValue(null, "name");
translatableAttr = parser.getAttributeBooleanValue(null, "translatable", true);
map.put(nameAttr, nameAttr);
sbKeys.append(nameAttr);
sbKeys.append("\n");
break;
}
}
}
else if (eventType == XmlResourceParser.END_TAG) {
//Log.d("XmlResourceParser", "End Tag " + parser.getName());
}
else if (eventType == XmlResourceParser.TEXT) {
//get the String value text
String text = parser.getText();
map.put(nameAttr, text);
sbValues.append(text);
sbValues.append("\n");
}
eventType = parser.next();
}
String sKeys = sbKeys.toString();
String sValues = sbValues.toString();
int i = 0; //<------- PUT A BREAK POINT HERE and point to sKeys or sValues and click + button and then click on VIEW button (in debug mode) and copy them all. Then Paste all sKeys in Excel in Column1 and sValues in Column2
} catch (Exception e) {
e.printStackTrace();
}
}
And you can call it like below in your onCreate method of your Activity:
parseResourceXML(getResources().getXml(R.xml.strings));
and put your strings.xml or localised strings_fr.xml under res/xml folder.
From the above script just put a break point into sKeys or sValues at the end and click the + button to view the data and then click on VIEW button (in debug mode) to see all data in plain text and now you can select them all and paste them in an Excel column. I hope it covers your case as well.
cmd
+shift
+A
. Or you can edit your keymaps by going to -Android Studio
->Preferences
->Keymap
(on Mac) – Ferren