Replies: 3 comments
-
Hi @thany - The If you wanted to introduce the heirarchy into your keys, then one option might be to use a key prefix convention that matches the folders you have. e.g.
|
Beta Was this translation helpful? Give feedback.
-
@ambrauer Prefixing makes for a LOT of extra data needing to be sent down the wire, and let's be honest: JSS already isn't very efficient in term of amounts of data. I don't like adding more. Nevertheless, if what you're saying is correct, and Sitecore cannot work with nested dictionary items, then:
I don't mind you closing this issue, and I don't even care that there's no workaround that you can think of (only a hack of sorts, that I can think of, as mentioned). But I would mind if this closure means to also completely forget about nested dictionary items at all. |
Beta Was this translation helpful? Give feedback.
-
@thany Sitecore definitely supports nested dictionary items but only from a content management perspective (i.e. in the content tree). From the API perspective (either using the REST or GraphQL service), the dictionary is flattened. So,
Thanks for the suggestion! |
Beta Was this translation helpful? Give feedback.
-
Describe the Bug
The typings for
DictionaryPhrases
demand that dictionary items are always flattened. When considering even a slightly large app, this will become tedious, and nested dictionary items become virtually essential.It bares mentioning that typescript module augmentation cannot work here, because as the term says, it can only augment modules, but not override what's already there. In other words, it can only add & merge types, but not overwrite any of them.
So this:
Does NOT work.
Another option would be to replace the entire set of typings, but then the responsibility on our end to keep them up-to-date means they won't be kept up-to-date anymore, practically speaking.
To Reproduce
There's nothing to reproduce, it's the typings that are wrong.
I'm referring to dictionary-service typings.
Expected Behavior
Nested or generic dictionary typings.
Possible Fix
Nested typings:
This would still be a hardcoded dictionary type, but at least it will make the typings correct both for applications, and in JSS internally, when using nested dictionary items. Projects not using nested dictionary items, are not inconvenienced by this, as flattened dictionaries will keep working just fine with this.
Generic typings:
Problem with this one is that while we can force incoming props to be properly typed by having them be of type
DictionaryPhrases<string | DictionaryPhrases>
, this will only allow one level deep nesting, AND it will not do anything for JSS internal typings - they'd still be wrong for nested dictionary items.I guess to fix the former, we'd need to go something a little bit like this:
And then use
NestedDictionaryPhrases
as the prop type fordictionary
in the<App>
component. Doesn't feel right, does it.Provide environment information
Beta Was this translation helpful? Give feedback.
All reactions