-
Notifications
You must be signed in to change notification settings - Fork 81
Description
We are usually using the Localized
component, but recently I was trying the withLocalization
's getString
API, and it looks like it is the missing the elems
parameter, which is pretty commonly used in Firefox Profiler.
Also wiki seems to be missing more advanced usage information. It's not possible to see other parameters here: https://github.com/projectfluent/fluent.js/wiki/withLocalization
So, I tried to check the implementation of getString and realized that it doesn't have a elems
parameter, like Localized:
fluent.js/fluent-react/src/localization.ts
Lines 33 to 52 in a1ac29d
getString( | |
id: string, | |
args?: Record<string, FluentVariable> | null, | |
fallback?: string | |
): string { | |
const bundle = this.getBundle(id); | |
if (bundle) { | |
const msg = bundle.getMessage(id); | |
if (msg && msg.value) { | |
let errors: Array<Error> = []; | |
let value = bundle.formatPattern(msg.value, args, errors); | |
for (let error of errors) { | |
this.reportError(error); | |
} | |
return value; | |
} | |
} | |
return fallback || id; | |
} |
Maybe there can be another way to pass these elements after getting the string, but I don't know how. I think it would be great to have an optional elems
parameter inside the getString
directly, so we can add elements directly with that API call.
To be clear, we are not blocked on this since Localized
is fixed now and we can continue using that. But it would be good to have this as well. What do you think?