Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Commit

Permalink
Treat 'tools:ignore="MissingTranslation"' as untranslatable (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Apr 15, 2018
1 parent 76d13f3 commit 969b224
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class ResourcesParser {
"translatable", "translate", "translateable"
};

// Nor they use "translatable" instead ignoring missing
private final static String TOOLS_IGNORE = "tools:ignore";
private final static String MISSING_TRANSLATION = "MissingTranslation";

private final static boolean DEFAULT_TRANSLATABLE = true;
private final static boolean DEFAULT_MODIFIED = false;
Expand Down Expand Up @@ -79,6 +82,11 @@ private static void readResourcesInto(final XmlPullParser parser, final Resource
throws XmlPullParserException, IOException {

parser.require(XmlPullParser.START_TAG, ns, RESOURCES);
if (MISSING_TRANSLATION.equals( parser.getAttributeValue(null, TOOLS_IGNORE))) {
// tools:ignore="MissingTranslation"
// Since missing translations can be ignored, they don't need a translation
return;
}

while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG)
Expand Down Expand Up @@ -115,6 +123,9 @@ private static ResString readResourceString(XmlPullParser parser)
boolean modified;

parser.require(XmlPullParser.START_TAG, ns, ResType.STRING.toString());
if (MISSING_TRANSLATION.equals( parser.getAttributeValue(null, TOOLS_IGNORE))) {
return null;
}

id = parser.getAttributeValue(null, ID);

Expand All @@ -140,6 +151,9 @@ private static Iterable<ResStringArray.Item> readResourceStringArray(XmlPullPars
String id;

parser.require(XmlPullParser.START_TAG, ns, ResType.STRING_ARRAY.toString());
if (MISSING_TRANSLATION.equals( parser.getAttributeValue(null, TOOLS_IGNORE))) {
return null;
}

if (!readFirstBooleanAttr(parser, TRANSLATABLE, DEFAULT_TRANSLATABLE)) {
// We don't care about not-translatable strings
Expand Down Expand Up @@ -180,6 +194,9 @@ private static Iterable<ResPlurals.Item> readResourcePlurals(XmlPullParser parse
String id;

parser.require(XmlPullParser.START_TAG, ns, ResType.PLURALS.toString());
if (MISSING_TRANSLATION.equals( parser.getAttributeValue(null, TOOLS_IGNORE))) {
return null;
}

if (!readFirstBooleanAttr(parser, TRANSLATABLE, DEFAULT_TRANSLATABLE)) {
// We don't care about not-translatable strings
Expand Down

0 comments on commit 969b224

Please sign in to comment.