changes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -287,7 +287,7 @@ class DocumentGenerator:
|
|||||||
return str(val)
|
return str(val)
|
||||||
if fmt_type == "number_to_words":
|
if fmt_type == "number_to_words":
|
||||||
try:
|
try:
|
||||||
return num2words(val, lang=fmt.get("lang", "en"))
|
return num2words(val, lang=fmt.get("lang", "vi"))
|
||||||
except Exception:
|
except Exception:
|
||||||
return str(val)
|
return str(val)
|
||||||
if fmt_type == "conditional":
|
if fmt_type == "conditional":
|
||||||
@@ -397,16 +397,37 @@ class DocumentGenerator:
|
|||||||
return placeholders
|
return placeholders
|
||||||
|
|
||||||
def _parse_format_args(self, args_string):
|
def _parse_format_args(self, args_string):
|
||||||
"""Parses a string like 'lang:vi, type:number_to_words' into a dictionary."""
|
|
||||||
if not args_string:
|
if not args_string:
|
||||||
return {}
|
return {}
|
||||||
format_config = {}
|
|
||||||
args = args_string.split(',')
|
parts = [p.strip() for p in args_string.split(',')]
|
||||||
for arg in args:
|
root = {}
|
||||||
if ':' in arg:
|
current = root
|
||||||
key, value = arg.split(':', 1)
|
|
||||||
format_config[key.strip()] = value.strip()
|
for part in parts:
|
||||||
return format_config
|
if ':' not in part:
|
||||||
|
continue
|
||||||
|
|
||||||
|
key, value = part.split(':', 1)
|
||||||
|
key = key.strip()
|
||||||
|
value = value.strip()
|
||||||
|
|
||||||
|
if key == "next":
|
||||||
|
# nếu next chưa tồn tại thì tạo
|
||||||
|
if "next" not in current or not isinstance(current["next"], dict):
|
||||||
|
current["next"] = {}
|
||||||
|
current = current["next"]
|
||||||
|
|
||||||
|
# hỗ trợ next:type:number_to_words
|
||||||
|
if ':' in value:
|
||||||
|
sub_key, sub_val = value.split(':', 1)
|
||||||
|
current[sub_key.strip()] = sub_val.strip()
|
||||||
|
else:
|
||||||
|
current[key] = value
|
||||||
|
|
||||||
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def prepare_replacements(self, doc):
|
def prepare_replacements(self, doc):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
,kumduy,duy-pc,15.01.2026 12:11,file:///home/kumduy/.config/libreoffice/4;
|
||||||
Binary file not shown.
Reference in New Issue
Block a user