Jump to content

User language


Blesta Addons

Recommended Posts

From v4.1.0, a new option was introduced for language that allow unauthenticated clients to select the language from a language selector .

in some blesta part, blesta ignore the selected language, and use the default company language, like the recaptcha, the knowledge base, and may be other place that i have not yet tested or notified about it.

so i suggest is better to change if the user already has selected a language and use it .

i don't know why blesta every time go to get the language from database if already it get it and set it the main controller, so i believe blesta it need only to use the Configure to get the selected language, and instead of every time make a call to get the company or client language.

Configure::get('Blesta.language')

https://requests.blesta.com/topic/user-language

 

Link to comment
Share on other sites

6 hours ago, Blesta Addons said:

in some blesta part, blesta ignore the selected language, and use the default company language, like the recaptcha, the knowledge base, and may be other place that i have not yet tested or notified about it.

Just to clarify, is this problem only with the language selector?  Or does it apply also to the client changing their language setting?  I only looked briefly, but it looks like our recaptcha does not support multiple languages, though it is might be possible for that to be updated.  

The knowledge base on my installation is working fine with the selector.  We are talking about client/plugin/support_manager/knowledgebase/, correct?   Do you have the language definitions in your chosen language for the support manager?

7 hours ago, Blesta Addons said:

i don't know why blesta every time go to get the language from database

I'm not really sure what you are referring to here.  I believe when ever we are deciding what language to display on a page, we do use Configure::get('Blesta.language').  Is there another circumstance you are talking about?

Link to comment
Share on other sites

as app_controller encoded i can't make a look at it, but i think the language is defined in the fallowing order :

1 - get the default company language, then set it in Language::setlang() and Configure::set('Blesta.language') .
2 - check if it a user, if yes then get the user's language and set it in Language::setlang() and Configure::set('Blesta.language') .
3 - if not a user and not a staff, check if the sessions has the 'blesta_language' defined,  if yes set it in Language::setlang() and Configure::set('Blesta.language') .

so after that,  we are sur we will use the correct language for every case.

in other place of Blesta, is not worth calling anymore the language to use, fro example in order plugin :

$company_settings['language']

in support manager

        // Set the company language
        $language = $this->SettingsCollection->fetchSetting(null, $this->company_id, 'language');
        if ($language && array_key_exists('value', $language)) {
            $language_codes = ['client' => $language['value'], 'company' => $language['value']];
        }

        // Set the client language
        if ($this->Session->read('blesta_client_id')
            && ($client = $this->Clients->get($this->Session->read('blesta_client_id')))
        ) {
            $language = $this->SettingsCollection->fetchClientSetting($client->id, null, 'language');
            if ($language && array_key_exists('value', $language)) {
                $language_codes['client'] = $language['value'];
            }
        }

normally the client language here is not the company language, if is a visitor and has changed the language, the company language will no more the selected language, and if is a user, then the language already set in the configure. so a simple line will be enough

        // Set the company & client language 
        $language = $this->SettingsCollection->fetchSetting(null, $this->company_id, 'language');
        if ($language && array_key_exists('value', $language)) {
            $language_codes = ['client' => Configure::get('Blesta.language'), 'company' => $language['value']];
        }

i hope i have well describe the situation .

Another thing that it should be in consideration, before any set for the language in the session we should first check if the language already installed, if not we should not set in the session or in the configure .

Link to comment
Share on other sites

On 8/26/2017 at 5:17 AM, Blesta Addons said:

3 - if not a user and not a staff, check if the sessions has the 'blesta_language' defined,  if yes set it in Language::setlang() and Configure::set('Blesta.language') .

Your description is mostly accurate.  The one correction is that a client user that is logged in can still use the language selector.

On 8/26/2017 at 5:17 AM, Blesta Addons said:

in other place of Blesta, is not worth calling anymore the language to use

Hmm, I see your point, but the configuration value and the client setting are not the same.  So if a user's language is set to English, but they use the language selector to change the language to Spanish, which should be used in the examples you gave.  I would still say the actual client setting as opposed to what was being used by the language selector.

**Note:  If your system is configured such that a client may change their language, the language selector will change the client setting and the two will always be the same.  If a contact user uses the language selector it will not change the setting.

On 8/26/2017 at 5:17 AM, Blesta Addons said:

Another thing that it should be in consideration, before any set for the language in the session we should first check if the language already installed, if not we should not set in the session or in the configure

This is done already.  client_main.php lines 880-885:

        if ($this->isStaffAsClient()
            || !isset($this->post['language_code'])
            || !($language = $this->Languages->get(Configure::get('Blesta.company_id'), $this->post['language_code']))
        ) {
            $this->redirect($this->base_uri);
        }

 

Link to comment
Share on other sites

I am just going through an issue with this. The client can easily click the language selector at the top, but it does not save his account to that language, he actually has to login to the user settings and save it in English. Just noticing this after an import of spanish users. I was testing emails and kept getting them in english despite selecting spanish in the selector, that does not work. It works after you login with the user and select spanish as the default language. (I do have spanish as the global language too)

Link to comment
Share on other sites

19 hours ago, Lucas said:

I am just going through an issue with this. The client can easily click the language selector at the top, but it does not save his account to that language, he actually has to login to the user settings and save it in English. Just noticing this after an import of spanish users. I was testing emails and kept getting them in english despite selecting spanish in the selector, that does not work. It works after you login with the user and select spanish as the default language. (I do have spanish as the global language too)

When the client is logged in through the primary user and uses the language selector, the system should update their language setting.  If they are logged in as a contact, this will not work since contacts do not have access to user settings.  Was the client using the primary login?  As far as emails, I believe you are correct in saying that the selector does not impact them unless in changes the client setting.  Which emails were you testing with?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...