mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
feat(core): plural function supports "key/keys" string
Previously function did not work for words ending with "y" and vowel before that
This commit is contained in:
parent
ecc0f6c445
commit
082b7ecd91
@ -39,7 +39,8 @@ def format_plural(string: str, count: int, plural: str) -> str:
|
||||
raise ValueError
|
||||
|
||||
if count == 0 or count > 1:
|
||||
if plural[-1] == "y":
|
||||
# candy -> candies, but key -> keys
|
||||
if plural[-1] == "y" and plural[-2] not in "aeiouy":
|
||||
plural = plural[:-1] + "ies"
|
||||
elif plural[-1] in "hsxz":
|
||||
plural = plural + "es"
|
||||
|
@ -17,10 +17,12 @@ class TestStrings(unittest.TestCase):
|
||||
|
||||
def test_format_plural(self):
|
||||
VECTORS = [
|
||||
("We need {count} more {plural}", 3, "share", "We need 3 more shares"),
|
||||
("We need {count} more {plural}", 1, "share", "We need 1 more share"),
|
||||
("We need {count} more {plural}", 3, "share", "We need 3 more shares"),
|
||||
("We need {count} more {plural}", 1, "candy", "We need 1 more candy"),
|
||||
("We need {count} more {plural}", 7, "candy", "We need 7 more candies"),
|
||||
("We need {count} more {plural}", 1, "key", "We need 1 more key"),
|
||||
("We need {count} more {plural}", 5, "key", "We need 5 more keys"),
|
||||
("We need {count} more {plural}", 1, "hash", "We need 1 more hash"),
|
||||
("We need {count} more {plural}", 2, "hash", "We need 2 more hashes"),
|
||||
("We need {count} more {plural}", 1, "fuzz", "We need 1 more fuzz"),
|
||||
|
Loading…
Reference in New Issue
Block a user