Hello, (Dear lazy sling community)
I'm working to implement my first sling application / pages. We have to deploy a *Terms of use* page that need to be translated across multiple languages. I figured this should be easy with Sling - and it's not quite as I expected :( . The solution that I have settled for in my head is using thymeleaf templates and sling i18n with json files. However I need some help implementing it. I'm sharing what is in my head, please help correct if I am wrong. I have been at this (and other sling related stuff - content loading, etc) for the past few days. My page is going to live in */content**/terms-of-us**e.ht**ml*. It's a *nt:file*, *sling:res**ource* with *sling:resourceType = **ieugen**/page* . Now, let's put translations for the page under */lib/trans**lations/content/t**erms**-of-use**.htlm/{english**.**json*, *deuts**ch.json}* . These files should follow the format described in [1]. My goal is for the content of the "/content/terms-of-use.html" node to be a thymeleaf template itself. This template will use attributes like th-text="#{text-id-from-translation-file}". Now, the script "*ieu**gen/page*" should to the following: - take the content of the JCR node - load the proper translation file based on the requested language and the node currently being rendered. - render the content of the node (thymeleaf template - or any other template language - handlebars?? ) by providing a context with the translation files loaded - extra: the content might be rendered inside a layout defined by ieugen/page script - with common headers and footers. My goal is to be able to create pages that are easy to internationalize. So far I have a few setbacks: 1. I don't know how to render resource properties. 2. I don't know how to render a template inside a script. So far, my script looks like this: <!DOCTYPE html> <html data-th-with="*valueMap=${resource.adaptTo(@org.apache.sling.api.resource.ValueMap@class)}*"> <head> <!-- Common head --> </head> <body> <div class="container"> <span data-th-text="${resource}">This works prints the resource </span> <span data-th-text="${valueMap.attribute['jcr:title']}">*This fails - valueMap is null* </span> <div> <p>*How do I render node content here**?**Node content is a thymeleaf? template* </p> </div> </div> <footer>Common footer</footer> </body> </html> Thanks, [1] https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based
signature.asc
Description: OpenPGP digital signature