mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 11:42:54 +03:00
String constructor for LocalizedValue
This allows you to do: LocalizedValue('thing'), which would result in a LocalizedValue looking like this: {'en': 'thing', 'ar': None}
This commit is contained in:
parent
2c5090f7a9
commit
3adfe509b2
@ -15,9 +15,12 @@ class LocalizedValue:
|
|||||||
different language.
|
different language.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for lang_code, _ in settings.LANGUAGES:
|
if isinstance(keys, str):
|
||||||
value = keys.get(lang_code) if keys else None
|
setattr(self, settings.LANGUAGE_CODE, keys)
|
||||||
setattr(self, lang_code, value)
|
else:
|
||||||
|
for lang_code, _ in settings.LANGUAGES:
|
||||||
|
value = keys.get(lang_code) if keys else None
|
||||||
|
setattr(self, lang_code, value)
|
||||||
|
|
||||||
def get(self, language: str=None) -> str:
|
def get(self, language: str=None) -> str:
|
||||||
"""Gets the underlying value in the specified or
|
"""Gets the underlying value in the specified or
|
||||||
|
Loading…
x
Reference in New Issue
Block a user