Localization Question #3178
-
Hey there, I'm working on localizing a web component built with Lit, and have run into an issue. Here is a simplified version of what I'm trying to do: render() {
const actions = {
ACCESS: 'ACCESS',
DELETE: 'DELETE',
MODIFY: 'MODIFY',
}
return html`
<div class="prompt-heading">${this.prompt}</div>
<div class="actions-container">
${Object.values(actions).map(
a =>
html`<action-item
action-name=${msg(a)}
action-description=""
?disabled=${true}
></action-item>`
)}
</div>
`;
} Basically I want to localize the value of each action type. This results in the following error when running
I'm confused by this error message because the type of a is string. Changing to <trans-unit id="saf63d34c8601dd41">
<source><x id="0" equiv-text="${a}"/></source>
</trans-unit> Which will not let me translate the actual action value (ACCESS, DELETE, or MODIFY). Any advice on how to proceed? I feel that this kind of thing can be done somehow, but haven't been able to find anything. Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
One way I can achieve what I want is by changing the code to: render() {
const actions = {
ACCESS: () => msg('ACCESS'),
DELETE: () => msg('DELETE'),
MODIFY: () => msg('MODIFY'),
}
return html`
<div class="prompt-heading">${this.prompt}</div>
<div class="actions-container">
${Object.values(actions).map(
a =>
html`<action-item
action-name=${a()}
action-description=""
?disabled=${true}
></action-item>`
)}
</div>
`;
} Is this the right solution, or is there some other way that I'm missing? |
Beta Was this translation helpful? Give feedback.
One way I can achieve what I want is by changing the code to:
Is this the right solution, or is there some other way that I'm missing?