-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add lang keys #45
Add lang keys #45
Conversation
maybe you can help me with quality review because the things are not so clear for me :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented inline
@@ -15,7 +15,19 @@ export const getters = { | |||
} | |||
|
|||
const { lang } = rootState.user.preferences.global; | |||
return state.i18n[lang] ? (state.i18n[lang][key] || key) : key; | |||
const { env } = rootState.meta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the env
const only when the if fails, so after the if
const { env } = rootState.meta; | ||
if (state.i18n[lang] && state.i18n[lang][key] !== undefined) { | ||
return (state.i18n[lang][key] || key); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the else is redundant because if the condition is true we return a value and we don't go past line 20. If the condition is false then we go to 21 with or without else.
// not needed | ||
}).catch((error) => { | ||
// not needed | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really an anti-pattern for vuex to make ajax calls from a getter. The getters should be responsible only with computing the state. To keep the convenience, we will go with this for now, but maybe in the future we can think of a better solution. Right now I can't find any other suggestion.
Let's do
if (env === 'local') {
axios.patch("/api/system/localisation/addLangKey", { langKey: key });
}
return key;
will do the changes |
There is still something else that I see as a problem.. when the request for adding a new key is made, the state is not changed. If we navigate to a diff page (without hitting refresh), and then come back, the request(s) will be made again and again. |
do we have the same problem if we change a translation in frontend?
maybe we should add an mechanism to update state after changing something? do you have an idea for this?
|
We have in the sense that the state is not updated.
We should, and this mechanism should work also for role permissions update |
ok, so at the moment it makes no difference because it’s already „wrong“ :)
|
not really.
this will happen only after the new implementation. |
yes for sure, but the request don’t change anything if key is already added.
so it increases load time only - which is a fact if developers know about this - which can be ignored (at the moment)?
|
I'm trying something and I'll get back on this. |
can you explain this to me in more detail - or what do I have to do now? |
We need to get the backend working with the new feature (in the localisation repo), and then uncomment this line https://github.com/laravel-enso/Core/blob/master/src/resources/assets/js/modules/enso/plugins/__.js#L8. I refactored the locale module to work with the new global helper We can close this PR. |
ok thx, will take a look on BE tomorrow.
can we add the store commit after adding/updating translations with UI too?
|
No description provided.