1
0
Fork 0

i18n Python scripts: fix Translation.__setitem__() and add docstrings

Translation.__setitem__() from flightgear/meta/i18n.py isn't used
anywhere here (it is not very useful), so no harm done, but that could
have confused potential readers.
This commit is contained in:
Florent Rougon 2018-10-11 20:32:48 +02:00
parent 2c41742b99
commit 359152c8d1

View file

@ -577,10 +577,25 @@ class Translation:
return ''.join(l) return ''.join(l)
def __getitem__(self, cat): def __getitem__(self, cat):
"""Get all translations for a given category.
Return a mapping where each key is a tid (instance of a subclass
of AbstractTranslationUnitId) and each value a TranslationUnit
instance.
"""
return self.translations[cat] return self.translations[cat]
def __setitem__(self, cat, translUnit): def __setitem__(self, cat, mapping):
self.translations[cat] = translUnit """Replace all translations for a given category.
cat: a category name (string such as 'sys', 'options', etc.)
mapping: a mapping where each key is a tid (instance of a
subclass of AbstractTranslationUnitId) and each value a
TranslationUnit instance.
"""
self.translations[cat] = dict(mapping)
def __iter__(self): def __iter__(self):
return iter(self.translations) return iter(self.translations)