I’m pretty sure that the best way to translate the Facet labels is to put translations into the Field in the KG. If that is not correct, please straighten me out.
Translating the actual values of the fields in facets when the values are a text lists (rather than an enumerated multi-select list) seems a little problematic, though. In some cases I have the same facet on several pages and there are a significant number of text values (like 20) that can appear in the field. I can’t enter the translations into the field in the KG, since the KG doesn’t know what values that field might take on.
Right now it appears that the only way to translate those values is to put the translations into the config/..json file in a facet.fields.fieldLabels array for each of these fields. Which, if true, means that the only way to propagate those translations is to copy/paste across multiple ..json files. Is there a better way or do I just bite the bullet here?
Thanks for submitting your question to the community! I’d like to ask some follow-up questions here.
Firstly, I just want to clarify that you are asking about translating the facet field option values and not the facet label itself.
What issues are you seeing with translating the values in the KG? When creating a text list field type, you can enable ‘Alternate Language Behavior’ (see screenshot) so that you can add the desired translations into the field directly in the KG.
If you’d prefer to do it on the frontend rather than in the KG, than your approach outlined above should work as well.
Let me know if this helps!
Yes, I was referring to the Values. And, no, I don’t want to mess with those by translating the values; that’s no good on a number of levels. Looks like I’ll have to bite the bullet and update those config files.
Honestly, though, I’m a bit surprised that you can’t put these translations into the .po file for a language. That would seem the right way to go about it.
On the frontend you totally could also update the .po files for a given language. That would be another way to do it. You’d have to generate a .po file per language you want to translate to so as long as we support all the languages that you would need, this approach works fine. Let me know if that doesn’t work for you.
Well, it appears that modifying the .po file doesn’t have any effect. I added a couple of the labels to one of the .po files but none are being translated in the Live View.
I looks like static/js/transform_facets.js, which is rendering the Facet labels, isn’t internationalized. I could probably override it if I knew the right function to call.