fnp
/
prawokultury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
favicon
[prawokultury.git]
/
migdal
/
helpers.py
diff --git
a/migdal/helpers.py
b/migdal/helpers.py
index
2de7ab0
..
8a6513d
100644
(file)
--- a/
migdal/helpers.py
+++ b/
migdal/helpers.py
@@
-20,7
+20,7
@@
class EntryType(namedtuple('EntryType', 'db slug commentable on_main')):
def field_getter(name):
@property
def getter(self):
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
if not val:
val = getattr(self, "%s_%s" % (name, settings.LANGUAGE_CODE))
return val
@@
-89,3
+89,9
@@
def add_translatable_index(index_class, fields, languages=None):
setattr(index_class, fname, new_field)
index_class.fields[fname] = new_field
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
+ )