The lang prop will need be on every Snap Preact component that has static text - it should contain an object that is keyed intuitively (maybe structurally) and consistently across them all. We also need to make room for accessibility language translations where applicable (typically aria attributes).
type LangType<P> = string | ((data: P) => string);
Each entry should support usage as either a primitive string or a function. The variables that are passed to each function will vary from component to component but thought should be put into ensuring consistent usage across all components.
Components will NOT have default values for the lang prop, instead the values provided there will overwrite any default values supplied within the component itself (via prop or otherwise).
The proposed solution is to utilize a hook in order to change element text contents or to add accessibility attributes. For example, adding the attribute ss-lang="showMoreLess" to an element would signify that this element supports the lang prop usage and the text would be found in lang.showMoreLess.text and any accessibility attributes would be found in lang.showMoreLess.a11y.
We need to ensure that there is no flashing of content changes, this would be a bad UX.
Proposed props for static text on every component:
The
lang
prop will need be on every Snap Preact component that has static text - it should contain an object that is keyed intuitively (maybe structurally) and consistently across them all. We also need to make room for accessibility language translations where applicable (typically aria attributes).Example Facet component lang prop:
Each entry should support usage as either a primitive string or a function. The variables that are passed to each function will vary from component to component but thought should be put into ensuring consistent usage across all components.
Components will NOT have default values for the
lang
prop, instead the values provided there will overwrite any default values supplied within the component itself (via prop or otherwise).The proposed solution is to utilize a hook in order to change element text contents or to add accessibility attributes. For example, adding the attribute
ss-lang="showMoreLess"
to an element would signify that this element supports thelang
prop usage and the text would be found inlang.showMoreLess.text
and any accessibility attributes would be found inlang.showMoreLess.a11y
.We need to ensure that there is no flashing of content changes, this would be a bad UX.