Skip to content

Commit 46e0783

Browse files
committed
Address comments 3
1 parent b8ccb99 commit 46e0783

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

localized_fields/value.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,27 @@ def localized(self):
238238

239239

240240
class LocalizedBooleanValue(LocalizedValue):
241-
def __bool__(self):
242-
"""Gets the value in the current language as a boolean."""
243-
value = self.translate()
241+
def translate(self):
242+
"""Gets the value in the current language, or in the configured fallbck
243+
language."""
244244

245-
if value is None:
246-
return self.default_value
247-
elif isinstance(value, bool):
245+
value = super().translate()
246+
if value is None or (isinstance(value, str) and value.strip() == ""):
247+
return None
248+
249+
if isinstance(value, bool):
248250
return value
249251

250252
if value.lower() == "true":
251253
return True
252254
return False
253255

256+
def __bool__(self):
257+
"""Gets the value in the current language as a boolean."""
258+
value = self.translate()
259+
260+
return value
261+
254262
def __str__(self):
255263
"""Returns string representation of value."""
256264

0 commit comments

Comments
 (0)