def field_getter(name):
@property
def getter(self):
- val = getattr(self, "%s_%s" % (name, get_language()))
+ val = getattr(self, "%s_%s" % (name, get_language()), None)
if not val:
val = getattr(self, "%s_%s" % (name, settings.LANGUAGE_CODE))
return val
setattr(index_class, fname, new_field)
index_class.fields[fname] = new_field
+
+def translated_fields(field_names, languages=settings.LANGUAGES):
+ return tuple("%s_%s" % (field_name, lang_code)
+ for field_name in field_names
+ for lang_code, lang_name in languages
+ )