mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-28 20:06:56 +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
|
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 = []
|
errs = []
|
||||||
if k.startswith("s_"):
|
if k.startswith("s_"):
|
||||||
if len(v) > s_max_len:
|
if len(v) > s_max_len:
|
||||||
@ -53,11 +53,11 @@ def check_prefixes(k, v, s_max_words, s_max_len):
|
|||||||
if ". " in v:
|
if ". " in v:
|
||||||
errs.append("Spans multiple sentences")
|
errs.append("Spans multiple sentences")
|
||||||
elif k.startswith("p_"):
|
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")
|
errs.append("Doesn't end in punctuation")
|
||||||
elif k.startswith("q_"):
|
elif k.startswith("q_"):
|
||||||
if not v.endswith("?"):
|
if q_endings and not any(v.endswith(q) for q in q_endings):
|
||||||
errs.append("Doesn't end in '?'")
|
errs.append("Doesn't end in question mark.")
|
||||||
return errs
|
return errs
|
||||||
|
|
||||||
|
|
||||||
@ -79,6 +79,8 @@ def lint_strings(strings, rules):
|
|||||||
v,
|
v,
|
||||||
rules.get("s_max_words", 4),
|
rules.get("s_max_words", 4),
|
||||||
rules.get("s_max_len", 32),
|
rules.get("s_max_len", 32),
|
||||||
|
rules.get("punctuation", [".", "!"]),
|
||||||
|
rules.get("q_endings", ["?"]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
errs.extend(check_misc(k, v))
|
errs.extend(check_misc(k, v))
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"@_lint_rules": {
|
"@_lint_rules": {
|
||||||
|
"punctuation": ["。", "!"],
|
||||||
|
"q_endings": ["?", "?"],
|
||||||
"s_max_words": 4,
|
"s_max_words": 4,
|
||||||
"s_max_length": 32
|
"s_max_length": 32
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user