Convert forbiddenTerms to a dict, and improve the output format.
This commit is contained in:
parent
650a2b84a1
commit
152d69ccf4
1 changed files with 16 additions and 18 deletions
|
|
@ -5,21 +5,19 @@ from xml.dom import minidom
|
||||||
|
|
||||||
file = sys.argv[1]
|
file = sys.argv[1]
|
||||||
|
|
||||||
# Arrays of forbidden terms, with exceptions for some keys
|
# Dict of forbidden terms, with exceptions for some String name
|
||||||
forbiddenTerms = [
|
# Keys are the terms, values are the exceptions.
|
||||||
[
|
forbiddenTerms = {
|
||||||
"Element",
|
"Element": [
|
||||||
[
|
# Those 2 strings are only used in debug version
|
||||||
# Those 2 strings are only used in debug version
|
"screen_advanced_settings_element_call_base_url",
|
||||||
"screen_advanced_settings_element_call_base_url",
|
"screen_advanced_settings_element_call_base_url_description",
|
||||||
"screen_advanced_settings_element_call_base_url_description",
|
# only used for element.io homeserver, so it's fine
|
||||||
# only used for element.io homeserver, so it's fine
|
"screen_server_confirmation_message_login_element_dot_io",
|
||||||
"screen_server_confirmation_message_login_element_dot_io",
|
# "Be in your element", will probably be changed on the forks, so we can ignore.
|
||||||
# "Be in your element", will probably be changed on the forks, so we can ignore.
|
"screen_onboarding_welcome_title",
|
||||||
"screen_onboarding_welcome_title",
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
}
|
||||||
|
|
||||||
content = minidom.parse(file)
|
content = minidom.parse(file)
|
||||||
|
|
||||||
|
|
@ -35,9 +33,9 @@ for elem in content.getElementsByTagName('string'):
|
||||||
continue
|
continue
|
||||||
value = child.nodeValue
|
value = child.nodeValue
|
||||||
# If value contains a forbidden term, add the error to errors
|
# If value contains a forbidden term, add the error to errors
|
||||||
for (term, exceptions) in forbiddenTerms:
|
for (term, exceptions) in forbiddenTerms.items():
|
||||||
if term in value and name not in exceptions:
|
if term in value and name not in exceptions:
|
||||||
errors.append('Forbidden term "' + term + '" in string: ' + name + ": " + value)
|
errors.append('Forbidden term "' + term + '" in string: "' + name + '": ' + value)
|
||||||
|
|
||||||
### Plurals
|
### Plurals
|
||||||
for elem in content.getElementsByTagName('plurals'):
|
for elem in content.getElementsByTagName('plurals'):
|
||||||
|
|
@ -52,9 +50,9 @@ for elem in content.getElementsByTagName('plurals'):
|
||||||
continue
|
continue
|
||||||
value = child.nodeValue
|
value = child.nodeValue
|
||||||
# If value contains a forbidden term, add the error to errors
|
# If value contains a forbidden term, add the error to errors
|
||||||
for (term, exceptions) in forbiddenTerms:
|
for (term, exceptions) in forbiddenTerms.items():
|
||||||
if term in value and name not in exceptions:
|
if term in value and name not in exceptions:
|
||||||
errors.append('Forbidden term "' + term + '" in plural: ' + name + ": " + value)
|
errors.append('Forbidden term "' + term + '" in plural: "' + name + '": ' + value)
|
||||||
|
|
||||||
# If errors is not empty print the report
|
# If errors is not empty print the report
|
||||||
if errors:
|
if errors:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue