Hey all - does anyone know of the best way to translate/localize hard-coded aria labels for accessibility purposes? We have a few areas where aria labels are included in the HubL with hard-coded English values in some instances.
I guess we could use the default HubL variables related to language (ex. content.language) to customize the text based on the page's language, but I can imagine that getting out of hand quickly if we start to localize to many different languages. Curious if there's a preferred method. Thanks!
I think the easiest solution for this would be to create locale files. An example of it can be found in the @hubspot/cmsdefaultpages folder inside the Design-Manager.
It's basically handling content with JSON files. The folder-structure should be:
{
"button_aria_label": {
"message": "Click this button to get the free whitepaper",
"description": "",
"placeholders": null
}
}
en_gb/messages.json:
{
"button_aria_label": {
"message": "Kindly click this button to obtain the complimentary whitepaper.",
"description": "",
"placeholders": null
}
}
de/messages.json:
{
"button_aria_label": {
"message": "Klicken Sie auf diese Schaltfläche, um das kostenlose Whitepaper herunterzuladen.",
"description": "",
"placeholders": null
}
}
Once done, open your template(s) and import the folder like this:
{% set template_translations = load_translations("./_locales", html_lang, "en") %}
"./_locales" is the path to the _locales folder, "en" sets the default language
I think the easiest solution for this would be to create locale files. An example of it can be found in the @hubspot/cmsdefaultpages folder inside the Design-Manager.
It's basically handling content with JSON files. The folder-structure should be:
{
"button_aria_label": {
"message": "Click this button to get the free whitepaper",
"description": "",
"placeholders": null
}
}
en_gb/messages.json:
{
"button_aria_label": {
"message": "Kindly click this button to obtain the complimentary whitepaper.",
"description": "",
"placeholders": null
}
}
de/messages.json:
{
"button_aria_label": {
"message": "Klicken Sie auf diese Schaltfläche, um das kostenlose Whitepaper herunterzuladen.",
"description": "",
"placeholders": null
}
}
Once done, open your template(s) and import the folder like this:
{% set template_translations = load_translations("./_locales", html_lang, "en") %}
"./_locales" is the path to the _locales folder, "en" sets the default language