[
https://issues.apache.org/jira/browse/SLING-4543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14379197#comment-14379197
]
Alexander Klimetschek edited comment on SLING-4543 at 3/25/15 8:51 PM:
---
Attached patch which adds json dictionary support: [^SLING-4543.patch]
If the mix:language dictionary node has a name like {{*.json}} and is an
nt:file, it will try to load this json, if not it will use the existing
sling:Message node.
The json format is straightforward: the parser will take _any_ key:value
pair in the dictionary, including in nested objects or arrays. Normally, a
dictionary will be just a single json object = hash map though.
For parsing, I used a streaming json parser from jackrabbit commons (already a
dependency) which is very fast. Loads 17000 strings across 3 json dictionaries
in 44ms on my machine.
I took the liberty to clean up the complex logic (rest, res0, etc. maps) -
which was obsolete with the previous changes that already load the dictionary
one by one (instead of a query across the repo, where each entry could come
from a different search path, each dictionary is loaded one by one and is
already beneath a certain search path or outside).
I also adapted the tests (some parts taken from Amit's patch over in
SLING-4512) and added one test case for json dictionaries and one that tests
that dictionaries outside the search path are overlayed by dictionaries within
a search path.
was (Author: alexander.klimetschek):
Attached patch which adds json dictionary support: [^SLING-4543.patch]
If the mix:language dictionary node has a name like {{*.json}} and is an
nt:file, it will try to load this json, if not it will use the existing
sling:Message node.
The json format is straightforward: the parser will take _any_ key:value
pair in the dictionary, including in nested objects or arrays. Normally, a
dictionary will be just a single json object = hash map though.
For parsing, I used a streaming json parser from jackrabbit commons (already a
dependency) which is very fast.
I took the liberty to clean up the complex logic (rest, res0, etc. maps) -
which was obsolete with the previous changes that already load the dictionary
one by one (instead of a query across the repo, where each entry could come
from a different search path, each dictionary is loaded one by one and is
already beneath a certain search path or outside).
I also adapted the tests (some parts taken from Amit's patch over in
SLING-4512) and added one test case for json dictionaries and one that tests
that dictionaries outside the search path are overlayed by dictionaries within
a search path.
i18n: support for json dictionaries
---
Key: SLING-4543
URL: https://issues.apache.org/jira/browse/SLING-4543
Project: Sling
Issue Type: Bug
Components: Extensions
Reporter: Alexander Klimetschek
Attachments: SLING-4543.patch
Support json dictionaries as alternative to individual sling:Message nodes.
The fine grained JCR sling:Message node approach does not scale very well
when dictionaries contain thousands of entries, at least installation of such
a dictionary is slow, but also reading can be affected (even if this is
cached), especially viewing in a tree browser becomes impossible.
The individual string overlay mechanism (/apps string overlays same /libs
string) must still work.
In our case (AEM) this can save more than a minute during installation time.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)