1
votes

So for example I would like to change the order of how language buttons are presented to the user from English - Chinese - French to Chinese - French - English.

I am assuming it is located in: zope.interface.interface-plone.app.i18n.locales.languageselector which is inside portal_view_customizations/registrations.html.

More specifically I am assuming it has to do with this piece of script:

> <tal:nonflag condition="python:not showFlags or not flag" replace="name">
>      language name 
> </tal:nonflag>

However I still do not know how or what am I supposed to write in order to control the language order on screen.

Any help would be appreciated.

2
From a convoluted source dive, it appears the order in the ZMI's portal_language tool is used, but you can't change it there directly. There is a way, but the margin is too small to contain it, so we'll have to wait for four other people to vote to re-open the question to allow answers. - Ulrich Schwarz
@Toto and the other moderators: The question is not too broad but very specific, please reopen. In general it might be good to know, that plone.org points users to come here with any question... - Ida

2 Answers

2
votes

There's no GUI to change the order of entries in the ZMI's portal_language tool (and that is the order that will be used on the page as far as I could find out).

However: in portal_setup, you can export the language settings, which will give you a file portal_languages.xml, wrapped inside an archive, with a content similar to the following:

<?xml version="1.0"?>
<object>
 <default_language value="en"/>
 <use_path_negotiation value="False"/>
 <use_cookie_negotiation value="True"/>
 <set_cookie_everywhere value="False"/>
 <use_request_negotiation value="True"/>
 <use_cctld_negotiation value="False"/>
 <use_content_negotiation value="True"/>
 <use_combined_language_codes value="False"/>
 <display_flags value="False"/>
 <start_neutral value="False"/>
 <use_subdomain_negotiation value="False"/>
 <authenticated_users_only value="False"/>
 <supported_langs>
  <element value="de"/>
  <element value="da"/>
  <element value="it"/>
  <element value="en"/>
  <element value="fr"/>
  <element value="cs"/>
 </supported_langs>
</object>

You can change the order of the lines in <supported_langs>, put the file back into the archive, and use "import uploaded tarball" in portal_setup's import function to apply the changed xml file.

Alternatively, you can create (and run via the "test" tab) a Script(Python) like this, which will first remove and then re-add the languages one by one in the desired order. (You might need to run the @@language-setup-folders step again afterwards if you use different folders and the root language switcher for your languages.)

# Return a string identifying this script.
print "This is the", script.meta_type, '"%s"' % script.getId(),
if script.title:
    print "(%s)" % html_quote(script.title),
print "in", container.absolute_url()

pl = context.portal_languages
pl.removeSupportedLanguages(pl.getSupportedLanguages())
print pl.supported_langs
pl.addSupportedLanguage('de')
pl.addSupportedLanguage('fr')
pl.addSupportedLanguage('da')
pl.addSupportedLanguage('en')
print pl.supported_langs

return printed

I tried going though the documented manage_setLanguageSettings method directly, but, at least in 4.3.2, that requires you to explicitly set all the other parameters (use cookie for language negotation et al.), so I wasn't too impressed.

2
votes

So I found a solution that works!

In order to rearrange the order of languages on your website that uses Plone CMS you need to follow these steps:

  1. go to Zope ([your website url]/manage_main)
  2. from there go to Portal View Customizations ([your website url]/portal_view_customizations/registrations.html)
  3. from there go to plone.app.i18n.locales.languageselector (Products.LinguaPlone.interfaces.ILinguaPloneProductLayer)
  4. from there add this piece of code <tal:language repeat="i python:[2,0,1]"> before the <li> tag, where [2,0,1] represents my chosen order. If you were to have a bigger list of languages then of course it would have been something like [0,1,2,3,4...e.t.c] which you can rearrange however you want.

Thank you @Ulrich Schwarz even though I couldn't make it work using your suggestions. I am sure it is possible to do via numerous ways including the ones you suggested.