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

Settings for server default language #1708

Merged

Conversation

jinchan-ck
Copy link
Contributor

#1614

Add the ability to set the default language for new users.
Admin can set server default language in admin/General section.

Add the ability to set the default language for new users.
Admin can set server default language in admin/General section.
@mariushop
Copy link

I was waiting for this one!

@jinchan-ck
Copy link
Contributor Author

I put the default server language setting in admin/General:
2e7a6361-fd4f-432c-9f40-d445d3ae1f98
@mariushop you can try my branch😄

@marceloschmidt
Copy link
Member

I think we should have an extra option under administration -> general -> language to leave the system as is, i.e., let the application choose the language based on user's browser. The way it is now, you have to select a default language for the app.

@jinchan-ck
Copy link
Contributor Author

@marceloschmidt you mean give a default value to the app language with the the language of user's browser?
But application will choose the language based on user's browser if no value set to the app language, we don't need to do that.

#Rocket.Chat/packages/rocketchat-ui-admin/admin/admin.coffee
appLanguage: (key) ->
        selected = (RocketChat.settings.get('Language') or defaultUserLanguage())?.split('-').shift().toLowerCase() is key
        return selected

#Rocket.Chat/client/startup/startup.coffee
@defaultAppLanguage = ->
    lng = window.navigator.userLanguage || window.navigator.language || 'en'
    # Fix browsers having all-lowercase language settings eg. pt-br, en-us
    re = /([a-z]{2}-)([a-z]{2})/
    if re.test lng
        lng = lng.replace re, (match, parts...) -> return parts[0] + parts[1].toUpperCase()
    return lng

@defaultUserLanguage = ->
    return RocketChat.settings.get('Language') || defaultAppLanguage()

    ......

Meteor.subscribe("userData", () ->
    userLanguage = Meteor.user()?.language
    userLanguage ?= defaultUserLanguage()

    if localStorage.getItem('userLanguage') isnt userLanguage
        localStorage.setItem('userLanguage', userLanguage)
        if isRtl localStorage.getItem 'userLanguage'
            $('html').addClass "rtl"

    setLanguage userLanguage

@jinchan-ck
Copy link
Contributor Author

@marceloschmidt Or you mean add an option for restoring to default language(base on user's browser)?

@marceloschmidt
Copy link
Member

What I mean is that once you save that setting in your server, users will lose the ability of reading your app in their native (browser) language, because there's no way of setting it back to blank.

@jinchan-ck
Copy link
Contributor Author

I think we need reach some agreements:

  1. This pr is an implementation for Settings for server default language #1614 ;
  2. Only admin has permission to modify the app language setting;
  3. Users are able to set language for their own, and it will cover app language;

And lets talk about some situations.
Once admin set a default language for the app(may be ja), which means he/she assume that users who are using the app are familiar with ja; and if some users are not familiar with ja by chance, they must be in minority in general. App admin won't change default language for the users in minority, and those part of users can set language by themselves.
In that case we do not need an option to set app language to blank, but if the app is for users all over the world, and the app admin set a local language(not en) for it by mistake, we need a way to set the app language to blank indeed.

So I will add a default option in the selection of app language so that app admin can set the app language back to blank, does that make sense? @marceloschmidt

@marceloschmidt
Copy link
Member

Yes, absolutely. And that is exactly the case for the Demo server. We have users all over the world, so we would like them to use demo.rocket.chat in their own languages. Once we set the default language of demo to 'en', for example, there is no way we can unset it, unless doing it directly in the database.

@jinchan-ck
Copy link
Contributor Author

Ok, i will work on it right now, thank you for your reply😄.

@jinchan-ck
Copy link
Contributor Author

@marceloschmidt I have added a default option to the app language selections, you can check it now.

@marceloschmidt
Copy link
Member

lgtm

@marceloschmidt
Copy link
Member

Thanks!

@engelgabriel
Copy link
Member

lgtm

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