Skip to content

How does one get <Localized elems> to not strip attributes? Alternatively, how does one explicitly wire up the attribute(s)? #669

Description

@ilyvion

I have this translation:

unit-days =
    { $value ->
        [one] { $value } <abbr title="day">d</abbr>
       *[other] { $value } <abbr title="days">d</abbr>
    }

which I'm trying to wire up like this:

// This is taking place inside a loop, hence the `key={unit}` and generated translation `id`
<Localized
    key={unit}
    id={`unit-${unit}`}
    vars={{ value }}
    elems={{
        abbr: <abbr />,
    }}
>
    <span className="whitespace-nowrap" />
</Localized>

and for the most part it works, except it renders as

<span class="whitespace-nowrap">59 <abbr>y</abbr></span>

instead of

<span class="whitespace-nowrap">59 <abbr title="years">y</abbr></span>

How do I shuttle that title into there from the translation? I'd prefer to not get l10n.getString involved, as that decouples the translation from the context. If there's a way to do this with fluent properties that'd also be fine, but as far as I can tell, the attrs on Localized only applies to the root element, not the elems elements. Right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions