-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of Arrays #84
Comments
Sorry, duplicate using lodash _.get wouldnt it help ? |
Hi @rbayley, Thank you for your feedback. Honestly, I am not completely sure anymore why we opted to use a flattened translation index. It is probably at least partially due to the way that the plugin evolved. We did try to provide users with a simple api to specify translation keys, while trying to keep the "lookup" method from becoming to costly. This is especially an issue, since the translation lookups are run every time the respective component is evaluated for re-rendering – unlike a computed property, that is only evaluated when corresponding elements in the vuex store are changed. However, I cannot recall if we actually did take some measurements on the computing time of a flattened index vs object lookups. In my opinion, the best solution would be, if there was a way to transform the lookup function into a computed property, so that it is only run if the locale or the keys in the store are changed. However, I have not yet had the time to look into this. Could you provide me with a snippet of how you would like to use an unflattened translation tree, so that I can think about how this could be implemented? |
Hi @tikiatua Thanks for your reply. The reason I need to keep the original non-flattened Object is that in some cases I need to loop through the content. For example. Therefore if I want to create a list (simple li tag) I can loop through "sections" and get correct data. Anyways, I have been looking into your code and thought about having two objects within the locale.
the ADD_LOCALE() mutation can update both the translations flattened object and the new unflattened. Not sure if or how this will hurt performance. Just a thought. |
Hi,
First, congrats on such a great job.
I notice vuex-i18n flattens arrays and so:
[
"before_or_equal" => "The :attribute must be a date before or equal to :date.",
"between" => [
"numeric" => "The :attribute must be between :min and :max.",
"file" => "The :attribute must be between :min and :max kilobytes.",
"string" => "The :attribute must be between :min and :max characters.",
"array" => "The :attribute must have between :min and :max items.",
],
"boolean" => "The :attribute field must be true or false."
]
Becomes
[
validation.before_or_equal:"The :attribute must be a date before or equal to :date."
validation.between.array:"The :attribute must have between :min and :max items."
validation.between.file:"The :attribute must be between :min and :max kilobytes."
validation.between.numeric:"The :attribute must be between :min and :max."
validation.between.string:"The :attribute must be between :min and :max characters."
validation.boolean:"The :attribute field must be true or false."
]
Why is this so ?
It would be interesting it didnt, that way we could loop through specific path.
If there is some option to do so, please let me know.
Thanks !
rb
The text was updated successfully, but these errors were encountered: