Skip to content

Commit

Permalink
Remove: do not check plural forms of translations.
Browse files Browse the repository at this point in the history
There is no need for NewGRF to use the same plural forms for languages as OpenTTD.
Sometimes the plural forms change, and when that happens erroring on existing NML NewGRF is unreasonable.
  • Loading branch information
frosch123 committed May 23, 2021
1 parent cac5bf1 commit cf928f1
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions nml/grfstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ def isint(x, base=10):
("zh_TW", 0x0C, 1),
]
LANG_NAMES = {lng[0]: lng[1] for lng in LANG_INFOS}
LANG_PLURALS = {lng[1]: lng[2] for lng in LANG_INFOS}


class Language:
Expand Down Expand Up @@ -1090,7 +1089,6 @@ def handle_grflangid(self, data, pos):
if value < 0 or value >= 0x7F:
raise generic.ScriptError("Invalid grflangid", pos)
self.langid = value
self.check_expected_plural(None)

def handle_plural(self, data, pos):
"""
Expand All @@ -1109,26 +1107,6 @@ def handle_plural(self, data, pos):
if value < 0 or value > NUM_PLURAL_FORMS:
raise generic.ScriptError("Invalid plural form", pos)
self.plural = value
self.check_expected_plural(pos)

def check_expected_plural(self, pos):
"""
Check whether the provided plural form of the language file
matches with the expected value for that language.
If not, raise an error.
@param pos: Position of the ##plural line, if position is available.
@type pos: L{Position}
"""
if self.plural is None or self.langid is None:
return

expected = LANG_PLURALS.get(self.langid)
if expected is not None and self.plural != expected:
msg = "Language with language id 0x{:02x} has plural form {:d} while the language uses plural form {:d}."
msg = msg.format(self.langid, self.plural, expected)
raise generic.ScriptError(msg, pos)

def handle_gender(self, data, pos):
"""
Expand Down

0 comments on commit cf928f1

Please sign in to comment.