1

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.

Azim
  • 51
  • 1
  • 11
  • 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 Oct 12 '15 at 17:40
  • @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 Oct 13 '15 at 06:38

2 Answers2

2

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.

Ulrich Schwarz
  • 7,598
  • 1
  • 36
  • 48
  • Nice solution for being very non-intrusive. – Ida Oct 14 '15 at 11:53
  • @Ulrich Schwarz Thank you! I followed your instructions but nothing seems to change. Does it have to do with the filename I give to my .tar.gz tarball? So far I have tried the same filename that I receive upon exporting the language settings, "Plone Language Tool.tar.gz" and "portal_languages.tar.gz". – Azim Oct 15 '15 at 14:14
  • @Azim: I _think_ the outer filename shouldn't matter, but the file inside needs to be named portal_languages.xml. (Anyway, I have an alternative idea at the back of my head, let me try that and get back to you.) – Ulrich Schwarz Oct 15 '15 at 14:52
  • @Ulrich Schwarz excuse me, but where exactly in zope should I upload that newly created Python file? – Azim Oct 19 '15 at 04:38
  • @Azim: go to /manage of your site, in the 'Add' dropdown select "Script (Python)", and paste it there. You can run the script by clicking "Test". – Ulrich Schwarz Oct 19 '15 at 05:15
  • @Ulrich Schwarz it returns: This is the Script (Python) "LangOrder" in http://www.inp.kz [] ['kk', 'ru', 'en'] – Azim Oct 19 '15 at 05:43
  • @Azim: and you should be able to verify that that is now the order listed in portal_languages, and also the order used on the content pages? – Ulrich Schwarz Oct 19 '15 at 06:22
2

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.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Azim
  • 51
  • 1
  • 11