eZ Community » Forums » eZ Publish 5 Platform » Switch language admin interface
expandshrink

Switch language admin interface

Switch language admin interface

Friday 29 May 2015 4:19:49 pm - 13 replies

Hi there,

I've read few topics about switching language in the admin interface, but i can't find exactly what i want (or i didn't understand).

Here is my question :

Is it possible for a connected user to switch the language of the admin directly from the interface, via a link "switch to FR/EN" or a flag for each country ?

I am aware that to change the language of the admin, i have to modify [RegionalSettings] and change the language there. But the users of the website will come from several countries and i'd like them to be able to switch by themselves.

Version : eZ 5.4

EDIT: is it possible to do it with a different siteaccess ?

Thanks, Cheers.

Modified on Friday 29 May 2015 5:56:13 pm by Task Mikaël

Saturday 30 May 2015 12:11:09 am

Hello Task,

Apologies for my late reply, I was pulled away from the internet today big-smile.gif Emoticon

The standard answer is, 'No'. You need to create separate siteaccesses for each language you wish the admin UI to be translated within.

I tried to think of ways to trigger code to run on every request at the start of the request but still have not thought of a very good one (without a kernel override say like, ezpkernelweb.php).

Because if I could, I am fairly certain I could us eZINI class to change the language ini settings on the fly per request (you think this would be costly in performance but it simply is not, like at all) in memory based on testing for a later to be set session variable indicating the language translation to use, which would do exactly what you want, then of course for actual control of the switching of the language you would create a custom module view to do the work of setting the session variable.

Then you would create a custom tpl to display a form ... say as a sidebar control (like the clear cache sidebar works) which would then the form would call the custom module to set the session var (language code like, ger-DE, fre-FR, etc) based on the change language form option menu drop down form selection value, set the session var, then redirect back to the previous page (which you might pass as well to the module view as a hidden form field containing the current page uri).

Once the custom language change module redirects, the ezpkernelweb class override with the eZINI language settings change code (in memory only, you *must not write this change to disk under any circumstance*) will detect the session variable, change the langue, leave the session variable in the session (this part is important) and continue to generate the page and send it to the user's web browser.

Whew, sorry for the run on sentences, I'm just prototyping out loud and I tend to be very specific and verbose. I've been holding back all day wanting to sit down and think about this more seriously.

Now that I think about that, I wouldn't have any initial concerns supporting this solution. It's fairly clean, requires only one kernel override of a legacy class that is very stable and not subject to much change (if at all) per release (which is important for maintainability), it would not affect performance in any way and the entire solution would be completely extension based (which I always insist upon, by default).

I would create the solution I just described it if a customer really wanted it, willing to fund the development, I think I could have a fairly stable and very clean beta in about oh 2 - 3 hours ... What do you think?

I really hope this helps! Have an excellent weekend!

Cheers,
Heath

Monday 01 June 2015 9:53:37 am

Hi !

Thanks for your time again. Sorry, I was off this week-end.

I guess it would be good to have this feature. Lacking of time for this task, I've implemented the solution based on siteacess (that is not working yet).

If you have done the developements already, i would be glad to test it.

Cheers.

Modified on Monday 01 June 2015 10:25:25 am by Task Mikaël

Monday 01 June 2015 11:36:54 am

Hello Task,

No worries on taking your time to reply. happy.gif Emoticon

I'm pleased you like my idea and would consider using it.

I have not started development on anything just yet and I'm fairly busy this week.

I'll consider trying to take some time soon to write a prototype and if I do make some more progress, I'll post an update here so you'll know.

As for your separate language admin siteaccesses configuration problems, just know that this part of eZ is rock solid and so your probably merely having configuration / setup issues ... which I'm sure you can work through. If you do need more specific help. Consider posting a very detailed question in a new separate forum thread and I'm sure we can help.

Best wishes

Cheers,
Heath

Tuesday 09 June 2015 7:38:42 am

Hello Task,

I have completed development, testing and documentation of the solution I described previously.

https://github.com/brookinsconsulting/bcswitchadminlanguage

Sorry for the delay in completing the work and responding.

It took a little longer to implement and test because we ran into problems with template, content and translation caching which by default is purely siteaccess based (generality) and not local / language based (given the default eZP assumptions that siteaccesses are by default local / language specific to begin with).

This meant we had to modify some additional cache path / key code (all clearly documented and very minimal) within our kernel class overrides to append the locale identifier to the siteaccess name to ensure that changing language means that caches using the previous local / language are not used.

To be clear, this solution does not disable -any- part of the default caching systems used in eZ Publish. The only modification we made was to change the cache storage and retrieval to be siteaccess name + local specific.

These were very small modifications which have very very minimal impact to the caching system and usage overall. In short this solution in general increases in a small way the amount of cache generated since you store more cache than normal by caching template, content and translation of more than a single language. This additional cache stored should not be a problem in any way and can be cleared at any time in the same ways you would by default.

Please let us know what you think of our solution!

Feel free to ask further questions!

I hope this helps you and others!

Cheers,
Heath

Friday 12 June 2015 4:34:14 pm

Hi there,

Thanks a lot for the extension !

I will test it soon and post back the results here as i didn't succeed in doing it otherwise.

Thanks again SlashSlash Heath !

Friday 12 June 2015 5:10:43 pm

Hi again,

Got a problem :

<select autocomplete="off" name="Language">
<option value="fre-FR">Français (France)</option>
<option value="eng-US">English (American)</option>
</select>

By default it is in english, when I want to switch to french nothing is happening.

Thanks Cheers.

Modified on Friday 12 June 2015 5:25:22 pm by Task Mikaël

Friday 12 June 2015 11:43:33 pm

Hello Task,

Thank you for your interest and thanks happy.gif Emoticon Apologies for my late reply.

EDIT: After posting in this message, updating the extension solution documentation and and re-reading this message I realized that I did not accurately enough respond to the intent of the message. As such this message has been heavily edited to clarify. 

Sorry for the trouble. I guess I expected that you already had your locale and language settings already in place. I'm short on time this evening so I'll be more brief than normal.

EDIT: Adding languages via the admin 'Setup -> Languages' module view is not required for administration UI translation as that step is only required for content object translation; As such I have removed these instructions; Sorry for the confusion.

Make sure in your 'settings/siteaccess/(adminSiteAccessName)/site.ini.append.php' settings you must add the language identifiers into your '[RegionalSettings] SiteLanguageList[]' settings array. Here is an example I had on hand of what it might look like:

[RegionalSettings]
Locale=eng-US
ContentObjectLocale=eng-US
ShowUntranslatedObjects=enabled
SiteLanguageList[]=eng-US
SiteLanguageList[]=fre-FR
SiteLanguageList[]=ger-DE
TextTranslation=enabled

Note: I think that the setting 'TextTranslation=enabled' is also required as that controls whether template (UI) translations occur. I will update the documentation on that part as well. 

Here is some semi-related documentation: https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Features/Multi-language/Configuring-the-site-languages

I will try to expand the extension documentation on these requirements and more clear instructions on how to do this over the weekend.

EDIT: I have updated the extension documentation to more clearly document the setup dependancies configuration documentation. Please re-read the provided documentation

EDIT: Per your actual message text, it now sounds like you have not correctly enabled and generated eZ Publish Legacy Kernel Overrides. How to complete this setup is covered within the 'Enable eZ Publish Kernel Overrides' and 'Regenerate kernel class override autoloads' sections of the documentation:

https://github.com/brookinsconsulting/bcswitchadminlanguage#enable-ez-publish-kernel-overrides

I hope this helps!

Cheers,
Heath

Modified on Sunday 14 June 2015 10:30:50 pm by // Heath

Sunday 14 June 2015 10:35:17 pm

Hello Task,

I have updated the extension documentation (see: repository's README.md).

I have updated my previous post to clarify some invalid and unclear instructions. I also point out that it seems you have not correctly enabled the provided kernel override which this feature depends.

Please carefully re-read the updated documentation in the repository. Study the installation and configuration setup instructions and please test to ensure that you have completed them correctly.

https://github.com/brookinsconsulting/bcswitchadminlanguage/blob/master/README.md

I also updated the extension's doc/TODO.md documentation to include some ideas for additional features and improvements.

https://github.com/brookinsconsulting/bcswitchadminlanguage/blob/master/doc/TODO.md

Please review the TODO.md and let me know if you have any need / interest in these possible improvements.

Cheers,
Heath

Modified on Sunday 14 June 2015 10:37:07 pm by // Heath

Monday 15 June 2015 11:18:25 am

Hi there,

Thanks for answering !

i forgot to rename the config file ... my bad. But now, i can't even connect to the admin interface. the login fails without saying anything.

as long as EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE is set to true, when i try to login nothing is happening.

Version 2014.11

Cheers.

Modified on Monday 15 June 2015 11:19:25 am by Task Mikaël

Monday 15 June 2015 2:52:40 pm

Hello Task,

Your very welcome.

Because of the complexity involved, I'm going to have to ask you document (itemize, share) each step you took to install and configure the solution before I can even begin to help you figure out what step you missed.

Also try tailing the 'var/log/error.log' to watch for any important error log entries when trying to login with kernel overrides enabled by config.php

Also are you certain that file, 'var/autoload/ezp_override.php' contains the PHP classes provided by this extension?

Please note that when you enable kernel overrides in the config.php file, the solution will not work unless you regenerate kernel override autoloads. This is clearly documented and shown in the extension installation documentation.

Have you customized the extension settings override setting, 'SharedAdminSiteaccessName' to contain your admin siteaccess name text string?

https://github.com/brookinsconsulting/bcswitchadminlanguage#extension-settings-override

For the record this solution was developed and tested with 2014.11 happy.gif Emoticon

So I know it works when setup correctly.

I hope this helps!

Cheers,
Heath 

Wednesday 17 June 2015 11:05:48 am

Hi again,

I have followed the installation guide line by line.

The logs are not showing anything suspicious related to the switch action.

except :
[ Jun 17 2015 11:43:12 ] [] eZDir::recursiveDelete:
The path: var/site_name/cache/template/compiled is not a folder
[ Jun 17 2015 11:43:12 ] [] eZDir::recursiveDelete:
The path: var/site_name/cache/override is not a folder

I have really spent too much time on this task and i'm not allowed to.

site access config in ezpublish.yml

         mysite_admin_siteaccess:
            languages: [eng-US, fre-FR]
            session:
                name: BACK
                cookie_lifetime: 43200
            legacy_mode: true
            content:
                view_cache: true
                ttl_cache: false
                default_ttl: 0

Don't know if this can help.

EDIT : I didn't install the extension via composer by the way. I have downloaded the extention and put it into the extention folder of ezpublish_legacy.

Thanks anyway, cheers.

Modified on Wednesday 17 June 2015 11:53:23 am by Task Mikaël

Thursday 18 June 2015 7:11:08 am

Hello Task,

This extension was tested only under dedicated legacy virtual host context.

We will need to test it under a dual stack context.

Sorry for the confusion.

Note: Installation via composer vs other methods is not an issue btw.

Note: The log errors you share indicate (I think) that your var directory files are not correctly owned by the same users as your webserver. This is something you should fix.

 

Cheers,
Heath

Thursday 02 July 2015 10:58:10 am

Hi all,

Thanks for everything, we have chosen the siteaccess solution, I forgot to tell you a while ago, but i've tried to install the extension, i went as far as i could but the logs weren't telling much. We have in deed a different environment, that is maybe the cause of the problem.

Thanks a lot.
Cheers.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from