[X] I agree to follow this project's Contributing Guidelines.
Description
Elements such as the bsCollapsePanel from the shinyBS library are frequency used to organize UI controls. As such, for international applications, being able to translate all elements in a UI is critical.
Problem
As currently implemented, translation cannot be directly enabled for the bsCollapsePanel since it doesn't appear to expose the appropriate data context for the shiny.i18n library to access. A work around is possible as demonstrated in the Proposed Solution, which suggests that it is is likely possible to add a cleaner (e.g., shiny.i18n::translate_panels(i18n) function call or the like) version to the library.
Proposed Solution
The following snippet enables translation of bsCollapsePanel elements:
# Add the i18n class and translation key to the bsCollapsePanel
HTML('
<script>
$(document).on("shiny:sessioninitialized", function(event) {
$("a[id^=\'ui-collapse\']").each(function() {
$(this).addClass("i18n");
$(this).attr("data-key", $(this).text());
});
});
</script>'),
Alternatives Considered
I've actually added the above code snippet to our own application, so the support is already present. Formalizing it as part of the shiny.i18n library would just make this more accessible to others for use.
Guidelines
Description
Elements such as the
bsCollapsePanel
from the shinyBS library are frequency used to organize UI controls. As such, for international applications, being able to translate all elements in a UI is critical.Problem
As currently implemented, translation cannot be directly enabled for the
bsCollapsePanel
since it doesn't appear to expose the appropriate data context for theshiny.i18n
library to access. A work around is possible as demonstrated in the Proposed Solution, which suggests that it is is likely possible to add a cleaner (e.g.,shiny.i18n::translate_panels(i18n)
function call or the like) version to the library.Proposed Solution
The following snippet enables translation of bsCollapsePanel elements:
Alternatives Considered
I've actually added the above code snippet to our own application, so the support is already present. Formalizing it as part of the
shiny.i18n
library would just make this more accessible to others for use.