Skip to content
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

[FIX] Default server language not being applied #11719

Merged
merged 3 commits into from Aug 10, 2018

Conversation

sampaiodiego
Copy link
Member

With the new logic, the user's language takes precedence, then the language stored on localStorage, then default server's language.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11719 August 8, 2018 22:13 Inactive
@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11719 August 8, 2018 23:35 Inactive
ggazzo
ggazzo previously approved these changes Aug 9, 2018
@@ -41,6 +41,9 @@ Meteor.startup(() => {
});

const applyLanguage = (language = 'en') => {
if (!language) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed? The language argument is always set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true.. during the development I got one situation where the param was null but with current implementation it is always set.. I'll remove this. thx

if (userLanguage && userLanguage !== currentLanguage.get()) {
setLanguage(userLanguage);
}
const user = RocketChat.models.Users.findOne(Meteor.userId(), { fields: { language: 1 }});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've to read this line five times before get it... 🐛

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 the diff didn't help =P


if (userLanguage && userLanguage !== currentLanguage.get()) {
setLanguage(userLanguage);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side effect of not invoking setLanguage(), the reactive currentLanguage variable is not changed and the form login will always show a suggested language. When nor user and admin language are set, e.g., the English version link is always present.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually setLanguage is still being called by the login form:

this is the only place that still calls it.

@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11719 August 9, 2018 12:31 Inactive
@sampaiodiego sampaiodiego added this to the 0.68.4 milestone Aug 9, 2018
@sampaiodiego
Copy link
Member Author

@tassoevan pls review it again =)

@sampaiodiego sampaiodiego merged commit 87cceb2 into develop Aug 10, 2018
@sampaiodiego sampaiodiego deleted the fix-default-language branch August 10, 2018 14:45
sampaiodiego added a commit that referenced this pull request Aug 10, 2018
* Fix default server language not being applied

* Always set user's language on localStorage
@sampaiodiego sampaiodiego mentioned this pull request Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants