mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 05:52:40 +03:00
Make punctuation customizable per language
This commit is contained in:
parent
a9a3ac7ecf
commit
7462f0f0b7
@ -40,7 +40,7 @@ def check_duplicate_values(strings):
|
||||
seen[v] = k
|
||||
|
||||
|
||||
def check_prefixes(k, v, s_max_words, s_max_len):
|
||||
def check_prefixes(k, v, s_max_words, s_max_len, punctuation, q_endings):
|
||||
errs = []
|
||||
if k.startswith("s_"):
|
||||
if len(v) > s_max_len:
|
||||
@ -53,11 +53,11 @@ def check_prefixes(k, v, s_max_words, s_max_len):
|
||||
if ". " in v:
|
||||
errs.append("Spans multiple sentences")
|
||||
elif k.startswith("p_"):
|
||||
if v[-1] not in ".!":
|
||||
if punctuation and not any(v.endswith(p) for p in punctuation):
|
||||
errs.append("Doesn't end in punctuation")
|
||||
elif k.startswith("q_"):
|
||||
if not v.endswith("?"):
|
||||
errs.append("Doesn't end in '?'")
|
||||
if q_endings and not any(v.endswith(q) for q in q_endings):
|
||||
errs.append("Doesn't end in question mark.")
|
||||
return errs
|
||||
|
||||
|
||||
@ -79,6 +79,8 @@ def lint_strings(strings, rules):
|
||||
v,
|
||||
rules.get("s_max_words", 4),
|
||||
rules.get("s_max_len", 32),
|
||||
rules.get("punctuation", [".", "!"]),
|
||||
rules.get("q_endings", ["?"]),
|
||||
)
|
||||
)
|
||||
errs.extend(check_misc(k, v))
|
||||
|
@ -16,6 +16,8 @@
|
||||
},
|
||||
|
||||
"@_lint_rules": {
|
||||
"punctuation": ["。", "!"],
|
||||
"q_endings": ["?", "?"],
|
||||
"s_max_words": 4,
|
||||
"s_max_length": 32
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user