enapps-enorman commented on PR #22:
URL:
https://github.com/apache/sling-org-apache-sling-scripting-sightly/pull/22#issuecomment-1341446382
One other concern I have is that perhaps I don't want others to replace the
basename for the i18n strings of my pages. Someone could abuse what is
proposed here to inject nonsense into the output. Is it really appropriate to
do such things without coordination with the original authors?
> @enapps-enorman nothing holding you back to do it that way, thats the
reason of the provider interface. If you make a
RequestAttributeBasenameProvider implementation and then set that attribute in
the PostConstruct of the Page object then you have exactly what you want? I’m
trying to keep it generic here so that anyway with their own wild idea can get
it to work for their situation ;)
Perhaps that could work for the first part of what I was discussing, but it
may not be quite as compatible with a solution of declaring the basename within
the HTL for the page or a block.
In other words, if the HTL syntax was extended (using a JSTL fmt style
approach) with a way to declare the basename for the page (or a block within
the page), then juggling a well known request attribute could be a way to
implement switching between the different basenames.
For example, I was thinking of a new syntax that looked something like this:
```
<!--/* before basename declared in the HTL so resolves to no basename
(or whatever was previously declared in the well-known request
attribute via
the page model, some servlet filter or otherwise) */-->
${"key1.from.not.locally.declared.basename.bundle" @ i18n}
<!--/* declare basename for the whole page */-->
<sly data-sly-i18n.setBundle="my.pagewide.basename.here"></sly>
<!--/* basename resolves to the pagewide basename */-->
${"key1.from.pagewide.bundle" @ i18n}
<!--/* declare basename for this block of elements */-->
<sly data-sly-i18n.bundle="my.block.basename.here">
<!--/* basename resolves to the block basename */-->
${"key2.from.block.bundle" @ i18n}
</sly>
<!--/* the block basename is now out of scope and we are back to the
pagewide basename again */-->
${"key2.from.pagewide.bundle" @ i18n}
```
Does that make sense?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]