From 2a392c290dd2b23400f37c9dc2ccc975d986d7fb Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 1 Sep 2020 19:10:07 +0200 Subject: [PATCH] Fix error in pluralization inflection. Resolves #2183. --- evennia/objects/objects.py | 13 +++++++------ evennia/utils/utils.py | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 35ea3089e2..862f7cd832 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -339,22 +339,23 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase): singular (str): The singular form to display. plural (str): The determined plural form of the key, including the count. """ + plural_category = "plural_key" key = kwargs.get("key", self.key) key = ansi.ANSIString(key) # this is needed to allow inflection of colored names try: - plural = _INFLECT.plural(key, 2) - plural = "%s %s" % (_INFLECT.number_to_words(count, threshold=12), plural) + plural = _INFLECT.plural(key, count) + plural = "{} {}".format(_INFLECT.number_to_words(count, threshold=12), plural) except IndexError: # this is raised by inflect if the input is not a proper noun plural = key singular = _INFLECT.an(key) - if not self.aliases.get(plural, category="plural_key"): + if not self.aliases.get(plural, category=plural_category): # we need to wipe any old plurals/an/a in case key changed in the interrim - self.aliases.clear(category="plural_key") - self.aliases.add(plural, category="plural_key") + self.aliases.clear(category=plural_category) + self.aliases.add(plural, category=plural_category) # save the singular form as an alias here too so we can display "an egg" and also # look at 'an egg'. - self.aliases.add(singular, category="plural_key") + self.aliases.add(singular, category=plural_category) return singular, plural def search( diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 3127fc25a2..bd5d460b5b 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -1917,6 +1917,10 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs): for num, result in enumerate(matches): # we need to consider Commands, where .aliases is a list aliases = result.aliases.all() if hasattr(result.aliases, "all") else result.aliases + # remove any pluralization aliases + aliases = [alias for alias in aliases if + hasattr(alias, "category") + and alias.category not in ("plural_key", )] error += _MULTIMATCH_TEMPLATE.format( number=num + 1, name=result.get_display_name(caller)