Skip to content

Commit

Permalink
fix(l10n): add l10n key to the state if it's not present (#656)
Browse files Browse the repository at this point in the history
Co-authored-by: nd0ut <[email protected]>
  • Loading branch information
nd0ut and nd0ut authored May 15, 2024
1 parent b148786 commit 227a88f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions abstract/l10nProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export function l10nProcessor(fr, fnCtx) {
);
// We don't need the leading * in the key because we use the key as a local context key relative to the global state
const nodeStateKey = localeStateKey(mappedKey).replace('*', '');
// If the key is not present in the node context, add it
if (!fnCtx.nodeCtx.has(nodeStateKey)) {
fnCtx.nodeCtx.add(nodeStateKey, mappedKey);
}
// Subscribe on the global l10n key change
const sub = fnCtx.nodeCtx.sub(nodeStateKey, () => {
el[/** @type {'textContent'} */ (elProp)] = fnCtx.l10n(mappedKey);
Expand Down

0 comments on commit 227a88f

Please sign in to comment.