Exclude non-translatable multiline blocks.
This commit is contained in:
parent
d53fd6a109
commit
b5656aa5dd
2 changed files with 30 additions and 7 deletions
|
@ -11,11 +11,13 @@
|
|||
<!-- L10N warnings -->
|
||||
<issue id="MissingTranslation" severity="ignore" />
|
||||
<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="ImpliedQuantity" severity="warning" />
|
||||
<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 id="CanvasSize" severity="error" />
|
||||
|
|
|
@ -79,18 +79,39 @@ task excludeNonTranslatables {
|
|||
.toSet()
|
||||
def all = english.collect { it['@name'] }.toSet()
|
||||
def translatable = all - nonTranslatable
|
||||
def inMultiline = false
|
||||
def endBlockName = ""
|
||||
|
||||
allStringsResourceFiles { f ->
|
||||
if (f != englishFile) {
|
||||
def newLines = f.readLines()
|
||||
.collect { line ->
|
||||
def matcher = line =~ /name="([^"]*)".*<\//
|
||||
if (matcher.find()) {
|
||||
def name = matcher.group(1)
|
||||
if (!line.contains('excludeNonTranslatables') && !translatable.contains(name)) {
|
||||
return " <!-- Removed by excludeNonTranslatables ${line.trim()} -->"
|
||||
if (!inMultiline) {
|
||||
def singleLineMatcher = line =~ /name="([^"]*)".*<\//
|
||||
if (singleLineMatcher.find()) {
|
||||
def name = singleLineMatcher.group(1)
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue