Hi Julian, OK understood, thanks so much for your help!
Thanks, Andrey. On Sun, Apr 26, 2020 at 5:32 AM Julian Sedding <jsedd...@gmail.com> wrote: > > Hi Andrey > > As the documentation states, you can use the SlingHttpServletRequest > object in your servlet implementations or rendering scripts to obtain > the locale of the request (as provided by the Accept-Language header). > And using this locale you can get a ResourceBundle instance. You can > then query the ResourceBundle with the definition string (aka key) in > order to obtain the translation. Of course you can also implement an > arbitrary other mechanism to load a ResourceBundle, e.g. you could get > the locale from a user-preference setting in a cookie. > > There is no mechanism that I know of that would redirect you to the > "correct" JSON file, and that is not what is documented. If you > want/need that, you will need to implement the logic in a custom > servlet yourself. > > Regards > Julian > > On Fri, Apr 24, 2020 at 5:37 PM Andrey Shulinsky <ashulin...@korio.ca> wrote: > > > > Hi Julian, > > > > Thanks a lot for the prompt reply. > > > > You advice has worked for a separate request: > > > > ---------------------------------------- > > POST http://localhost:8123/libs/languages/english.json HTTP/1.1 > > Content-Type: application/x-www-form-urlencoded > > User-Agent: Fiddler > > Host: localhost:8123 > > Content-Length: 43 > > Authorization: Basic YWRtaW46YWRtaW4= > > > > jcr:mixinTypes=mix:language&jcr:language=en > > ---------------------------------------- > > > > With that we now have the node > > jcr:root/libs/languages/english.json > > { > > "jcr:language": "en", > > "jcr:mixinTypes": [ > > "mix:language" > > ], > > "jcr:primaryType": "nt:file" > > } > > > > Which has this child node: > > jcr:root/libs/languages/english.json/jcr:content > > { > > "jcr:data": > > "/bin/cpm/nodes/property.bin/libs/languages/english.json/_jcr_content?name=jcr%3Adata", > > "jcr:mimeType": "application/json", > > "jcr:primaryType": "nt:resource" > > } > > > > > > We have also created the jcr:root/libs/languages/deutch.json resource > > in the same way. > > > > We have not tried the single request yet, would like to understand how > > to get the language-specific content first. > > > > We can do a GET > > http://localhost:8123/libs/languages/[english|deutch].json which > > returns the corresponding bundle however to our understanding this is > > not the right way to get the language-specific information. > > > > The docs at > > https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html > > mention the Accept-Language header. > > So we tried to use it with the requests like > > > > ---------------------------------------- > > GET http://localhost:8123/libs/languages HTTP/1.1 // Also tried > > http://localhost:8123/libs/languages/* and a few others > > Content-Type: text/json // Tried some other content types there > > Host: localhost:8123 > > Content-Length: 0 > > Authorization: Basic YWRtaW46YWRtaW4= > > Accept-Language: en > > ---------------------------------------- > > > > Nothing has worked so far unfortunately. > > > > > > Any advice please? > > > > > > Thanks, > > Andrey. > > > > On Fri, Apr 24, 2020 at 3:56 AM Julian Sedding <jsedd...@gmail.com> wrote: > > > > > > Hi > > > > > > I noticed that you set jcr:primaryType=mix:language. It should be > > > jcr:mixinTypes. > > > > > > Also no need to set the jcr:primaryType=nt:file, it should be set > > > automatically. Setting it again explicitly might actually cause issues. > > > > > > So just try posting > > > > > > ./jcr:mixinTypes=mix:language > > > ./jcr:language=en > > > > > > If that works in a separate request, you could try combining them into a > > > single request. > > > > > > Regards > > > Julian > > > > > > On Fri, 24 Apr 2020 at 03:47, Andrey Shulinsky <ashulin...@korio.ca> > > > wrote: > > > > > > > Hi folks, > > > > > > > > We're trying to use this bundle with the JSON file option: > > > > > > > > https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based > > > > > > > > Have been having an issue we'd really appreciate help with. > > > > > > > > > > > > We'd like to add the language-specific bundles using the POST API. > > > > > > > > > > > > This is the structure from the doc mentioned above: > > > > /libs/languages > > > > +-- english.json (nt:file, mix:language) > > > > | +-- jcr:language = en > > > > | +-- jcr:content (nt:resource) > > > > | + jcr:data (containing the actual JSON file) > > > > > > > > > > > > When we do this request: > > > > > > > > > > > > -------------------------------- > > > > POST http://localhost:8123/libs/languages HTTP/1.1 > > > > Content-Type: multipart/form-data; > > > > boundary=-------------------------acebdf13572468 > > > > User-Agent: Fiddler > > > > Host: localhost:8123 > > > > Content-Length: 257 > > > > Authorization: Basic YWRtaW46YWRtaW4= > > > > > > > > ---------------------------acebdf13572468 > > > > Content-Disposition: form-data; name="english.json"; > > > > filename="english.json" > > > > Content-Type: application/json > > > > > > > > { > > > > "message1": "aaa", > > > > "message2": "bbb" > > > > } > > > > > > > > ---------------------------acebdf13572468-- > > > > -------------------------------- > > > > > > > > We get a similar structure: > > > > > > > > /libs/languages > > > > +-- english.json (nt:file) > > > > | +-- jcr:content (nt:resource) > > > > | + jcr:data (containing the actual JSON file) > > > > > > > > And the messages1-2 are added properly. > > > > > > > > However it's lacking > > > > - the "mix:language" type on the english.json node > > > > - the jcr:language=en property on the english/json node > > > > Which are needed to get the proper language-specific content > > > > > > > > We have tried to modify the request above to add those properties, > > > > tried a separate request to add them: > > > > > > > > -------------------------------- > > > > POST http://localhost:8123/libs/languages/english.json HTTP/1.1 > > > > Content-Type: application/x-www-form-urlencoded > > > > User-Agent: Fiddler > > > > Host: localhost:8123 > > > > Content-Length: 52 > > > > Authorization: Basic YWRtaW46YWRtaW4= > > > > > > > > jcr:primaryType=nt:file&jcr:primaryType=mix:language > > > > -------------------------------- > > > > > > > > But nothing has worked so far. > > > > > > > > So if anyone could do us a favor and advise how to add those > > > > properties that would be really helpful. > > > > > > > > Thanks in advance! > > > > > > > > Andrey. > > > >