Re: Sling pipes release

2017-04-27 Thread Correia
Thanks everyone for the help.

I really don't understand how it's supposed to work the example discribed in
Sling Internationalization page.

The "ignoreImportProviders=json" is not a solution because I use JSON for
all my content.

I will keep my working attempt described in first post for now.
It works great in HTML with Sightly annotation ${key @i18n}.
My problem is how to read it in Javascript...

Best Regards.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/Sling-JSON-i18n-tp4072998p4073049.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Sling pipes release

2017-04-27 Thread Alexander Klimetschek
On 27.04.2017, at 06:12, Correia  wrote:
> How do I add my second JSON file to the jcr:data on the first file??

The answer to that question must lie in the sling initial content loader 
mechanism, how it can incorporate binary files (i.e. the second en.json that 
should end up as-is as nt:file in the repository). It probably sees all json 
files as descriptor files and tries to read them as jcr content.

Using "ignoreImportProviders=json" won't help, as then the english.json would 
no longer be seen as descriptor file either.

You could turn the english.json into the xml descriptor format, and use 
"ignoreImportProviders=json"… that might not be perfect if you prefer the json 
descriptor format I guess.

Note I am not very familiar with the content loader mechanism and if there is a 
better way.

Cheers,
Alex


Re: Sling pipes release

2017-04-27 Thread Correia
Not getting there yet :p

Let me reformulate my question...

I'm trying to use the Internationalization Support as the example in Sling
documentation:
https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html

I'm using JSON-file based

As the example describe...
   /libs/languages
   +-- english.json (nt:file, mix:language)
   |+-- jcr:language = en
   |+-- jcr:content (nt:resource)
   | + jcr:data (containing the actual JSON file)
   +-- deutsch.json (nt:file, mix:language)
+-- jcr:language = de
+-- jcr:content (nt:resource)
+ jcr:data (containing the actual JSON file)

I want to have two JSON files.

english.json (with node description)
{ 
"jcr:primaryType": "nt:file", 
"jcr:mixinTypes": "[mix:language]", 
"jcr:language": "en", 
"jcr:content": { 
"jcr:primaryType": "nt:resource", 
"jcr:data": { 
} 
} 
} 

en.json (with i18n key:value)
{
"hello": "Hello",
...
}

How do I add my second JSON file to the jcr:data on the first file??



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/Sling-JSON-i18n-tp4072998p4073026.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Sling pipes release

2017-04-27 Thread Nicolas Peltier
Hi,

Is it possible to fix SLING-6800 and create a 0.0.12 release for sling pipes?

Thanks,
Nicolas


Re: Sling JSON i18n

2017-04-27 Thread Bertrand Delacretaz
Hi,

On Thu, Apr 27, 2017 at 1:01 PM, Correia
 wrote:
> ...I'm importing the files to the JCR repository via maven and i'm using JSON
> instead of XML...

Ah ok got it, your problem is how to provide those json files as
initial content in your source code, without them being interpreted by
the initial content loading mechanism.

https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html
should help for that, if you use the "ignoreImportProviders=json"
directive in your bundle's Sling-Initial-Content header the json files
should appear as is in the content repository.

The contrib/jcr/js/nodetypes module has an example.

Let us know if that works for you!

-Bertrand


Re: Sling JSON i18n

2017-04-27 Thread Correia
Thanks for the help.
I had already readed that documentation, but my problem is how I build my
JSON file.
I'm importing the files to the JCR repository via maven and i'm using JSON
instead of XML.

My question is how to build the JSON file under libs/languages.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/Sling-JSON-i18n-tp4072998p4073012.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Sling JSON i18n

2017-04-27 Thread Bertrand Delacretaz
On Thu, Apr 27, 2017 at 12:14 PM, Correia
 wrote:
> ...What I wanted to do is having a pure JSON file like:
> {
> "hello": "Hello",
> "hello2": "Hello 2"
> }
>
> Is this possible...

Yes, as described in the docs.

The corresponding test is JcrResourceBundleTest.test_json_dictionary()
[1], it's not too readable as the json is created inline but should
provide the information that you're looking for.

-Bertrand

[1] 
https://github.com/apache/sling/blob/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java


Re: Sling JSON i18n

2017-04-27 Thread Correia
Yes, that example is similar to the one I have working.

What I wanted to do is having a pure JSON file like:
{
"hello": "Hello",
"hello2": "Hello 2"
}

Is this possible?

Follow up question...
With the suggested example I can use slightly annotation to get the label
${'hello' @i18n}.
How can I use i18n in javascript?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/Sling-JSON-i18n-tp4072998p4073009.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Sling JSON i18n

2017-04-27 Thread Chris Millar
Have a look at: 
https://github.com/auniverseaway/slick-2/tree/master/ui.apps/src/main/resources/jcr_root/libs/languages

I can verify this works on pure Sling 8.

Let me know if you have any additional questions.

> On Apr 26, 2017, at 3:23 PM, Correia  
> wrote:
> 
> Hi all,
> 
> I'm trying to use the Internationalization Support based inJSON as described
> in Sling example:
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> 
> I'm having trouble creating the JSON. Can anyone provide an example?
> 
> My working attenpt:
> {
>"jcr:primaryType": "nt:folder",
>"jcr:mixinTypes": ["mix:language"],
>"jcr:language": "en",
>"hello": {
>"jcr:primaryType": "sling:MessageEntry",
>"sling:message": "Hello"
>},
>"hello2": {
>"jcr:primaryType": "sling:MessageEntry",
>"sling:message": "Hello 2"
>}
> }
> 
> But Î want to use as key:value.
> 
> Using the page example should be something like:
> {
>"jcr:primaryType": "nt:file",
>"jcr:mixinTypes": "[mix:language]",
>"jcr:language": "en",
>"jcr:content": {
>"jcr:primaryType": "nt:resource",
>"jcr:data": {
>"hello": "Hello",
>"hello2": "Hello 2"
>}
>}
> }
> 
> Issues:
> 1) type "nt:file" dont allow me to define jcr:language ( No matching
> property definition: jcr:language = en)
> 2) Missing some defenition in jcr:data (No matching property definition:
> jcr:data)
> 
> PS: I'm using pure Sling. No AEM nor CQ.
> 
> Thanks,
> Carlos Correia
> 
> 
> 
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/Sling-JSON-i18n-tp4072998.html
> Sent from the Sling - Users mailing list archive at Nabble.com.