Skip to content

Commit 2a0d3f3

Browse files
committed
Add attribute formatting functionality in FluentLocalization
1 parent e4fc3c2 commit 2a0d3f3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fluent.runtime/fluent/runtime/fallback.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ def format_value(
5252
self, msg_id: str, args: Union[Dict[str, Any], None] = None
5353
) -> str:
5454
for bundle in self._bundles():
55+
attr: str | None = None
56+
if "." in msg_id:
57+
msg_id, attr = msg_id.split(".", maxsplit=1)
5558
if not bundle.has_message(msg_id):
5659
continue
57-
msg = bundle.get_message(msg_id)
60+
if attr is None:
61+
msg = bundle.get_message(msg_id)
62+
else:
63+
msg = bundle.get_message(msg_id).attributes[attr]
5864
if not msg.value:
5965
continue
6066
val, _errors = bundle.format_pattern(msg.value, args)

0 commit comments

Comments
 (0)