Skip to content

[FIX] Default server language not being applied#11719

Merged
sampaiodiego merged 3 commits intodevelopfrom
fix-default-language
Aug 10, 2018
Merged

[FIX] Default server language not being applied#11719
sampaiodiego merged 3 commits intodevelopfrom
fix-default-language

Conversation

@sampaiodiego
Copy link
Copy Markdown
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 force-pushed the fix-default-language branch from 39fb9ec to 8bfa598 Compare August 8, 2018 23:34
@sampaiodiego sampaiodiego temporarily deployed to rocket-chat-pr-11719 August 8, 2018 23:35 Inactive
ggazzo
ggazzo previously approved these changes Aug 9, 2018
const applyLanguage = (language = 'en') => {
if (!language) {
return;
}
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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.

4 participants