Exclude non-translatable multiline blocks.
parent
d53fd6a109
commit
b5656aa5dd
|
@ -11,11 +11,13 @@
|
||||||
<!-- L10N warnings -->
|
<!-- L10N warnings -->
|
||||||
<issue id="MissingTranslation" severity="ignore" />
|
<issue id="MissingTranslation" severity="ignore" />
|
||||||
<issue id="MissingQuantity" severity="warning" />
|
<issue id="MissingQuantity" severity="warning" />
|
||||||
<issue id="MissingDefaultResource" severity="warning" />
|
<issue id="MissingDefaultResource" severity="error">
|
||||||
|
<ignore path="*/res/values-*/strings.xml" /> <!-- Ignore for non-English, excludeNonTranslatables task will remove these -->
|
||||||
|
</issue>
|
||||||
<issue id="ExtraTranslation" severity="warning" />
|
<issue id="ExtraTranslation" severity="warning" />
|
||||||
<issue id="ImpliedQuantity" severity="warning" />
|
<issue id="ImpliedQuantity" severity="warning" />
|
||||||
<issue id="TypographyDashes" severity="error" >
|
<issue id="TypographyDashes" severity="error" >
|
||||||
<ignore path="*/res/values-*" /> <!-- Ignore for non-English -->
|
<ignore path="*/res/values-*/strings.xml" /> <!-- Ignore for non-English -->
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
<issue id="CanvasSize" severity="error" />
|
<issue id="CanvasSize" severity="error" />
|
||||||
|
|
|
@ -79,18 +79,39 @@ task excludeNonTranslatables {
|
||||||
.toSet()
|
.toSet()
|
||||||
def all = english.collect { it['@name'] }.toSet()
|
def all = english.collect { it['@name'] }.toSet()
|
||||||
def translatable = all - nonTranslatable
|
def translatable = all - nonTranslatable
|
||||||
|
def inMultiline = false
|
||||||
|
def endBlockName = ""
|
||||||
|
|
||||||
allStringsResourceFiles { f ->
|
allStringsResourceFiles { f ->
|
||||||
if (f != englishFile) {
|
if (f != englishFile) {
|
||||||
def newLines = f.readLines()
|
def newLines = f.readLines()
|
||||||
.collect { line ->
|
.collect { line ->
|
||||||
def matcher = line =~ /name="([^"]*)".*<\//
|
if (!inMultiline) {
|
||||||
if (matcher.find()) {
|
def singleLineMatcher = line =~ /name="([^"]*)".*<\//
|
||||||
def name = matcher.group(1)
|
if (singleLineMatcher.find()) {
|
||||||
if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) {
|
def name = singleLineMatcher.group(1)
|
||||||
return " <!-- Removed by excludeNonTranslatables ${line.trim()} -->"
|
if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) {
|
||||||
|
return " <!-- Removed by excludeNonTranslatables ${line.trim()} -->"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
def multilineStartMatcher = line =~ /<(.*) .?name="([^"]*)".*/
|
||||||
|
if (multilineStartMatcher.find()) {
|
||||||
|
endBlockName = multilineStartMatcher.group(1)
|
||||||
|
def name = multilineStartMatcher.group(2)
|
||||||
|
if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) {
|
||||||
|
inMultiline = true;
|
||||||
|
return " <!-- Removed by excludeNonTranslatables ${line.trim()}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
def multilineEndMatcher = line =~ /<\/${endBlockName}/
|
||||||
|
if (multilineEndMatcher.find()) {
|
||||||
|
inMultiline = false
|
||||||
|
return "${line} -->"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return line
|
return line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue