Repository: plone/Products.CMFPlone

Issue:
adding site with default language 'de-at' breaks
With current Plone 5 beta 1 and the merged language control panel, adding a site with a language like 'de-at' breaks and gives the following traceback:

```
2015-04-01 20:25:30 ERROR Zope.SiteErrorLog 1427912730.490.962488456232 http://localhost:8888/@@plone-addsite
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFPlone.browser.admin, line 232, in __call__
  Module Products.CMFPlone.factory, line 95, in addPloneSite
  Module plone.registry.registry, line 47, in __setitem__
  Module plone.registry.record, line 83, in _set_value
  Module zope.schema._bootstrapfields, line 182, in validate
  Module zope.schema._field, line 389, in _validate
ConstraintNotSatisfied: de-at
```

Please note, 'de-at' is selected by default, as reported by my browser.
- `Products.CMFPlone.browser.admin.AddPloneSite.languages` uses `plone.i18n.locales.interfaces.IContentLanguageAvailability` and constructs a list of languages with combined language codes, if the default language as reported by the browser contains a "-".
- `Products.CMFPlone.interfaces.controlpanel.ILanguageSchema.use_combined_language_codes` as a default value of False.
- `plone.app.vocabularies.language.AvailableContentLanguageVocabulary` constructs it's language list via `plone.i18n.utility.LanguageUtility.getAvailableLanguages` according to the setting `use_combined_language_codes`, which is False by default.

I guess, we have to set `use_combined_language_codes` to True in CMFPlone/factory, if CMFPlone/admin/AddPloneSite decides to use combined language codes...



Discussion:
^^^ @bloodbare @tisto 

workaround for a successful install: choose 'de' or anything else as long it is not a combined language when adding a site.

confirmed over here

The problem is still there in the 5.0b2 (fr-ch)

Currently we don't have an option to select a combined language. Not sure why yet.

Right, it only shows when your browser says it's language is something with a '-' in it.

@thet 
Would it be acceptable to only allow 'DE' in plone-addsite, and use plone_control_panel to select a specific locale?

IMO 5.0 should definitely allow specific locales but for a post-sprint 5.0b3 it's very acceptable :)

@jaroel i'm not sure if i like to remove the ability to use combined language codes (even if your pull https://github.com/plone/Products.CMFPlone/pull/684 simplifies the code :) )

IIRC, it would be enough to let the `use_combined_language_codes` setting in `Products.CMFPlone.interfaces.controlpanel` default to `True`.

Do we see a good reason not to show the whole list by default?
The browser language is already selected.

It can be tricky for most of the sites to need to choose between different english flavous. 


Resolving patch:
diff --git a/Products/CMFPlone/interfaces/controlpanel.py b/Products/CMFPlone/interfaces/controlpanel.py
--- a/Products/CMFPlone/interfaces/controlpanel.py
+++ b/Products/CMFPlone/interfaces/controlpanel.py
@@ -147,7 +147,7 @@ class ILanguageSchema(Interface):
             default=u"Examples: pt-br (Brazilian Portuguese), "
                     u"en-us (American English) etc."
         ),
-        default=False,
+        default=True,
         required=False
     )
 


Test patch:
diff --git a/Products/CMFPlone/controlpanel/tests/test_controlpanel_bbb_language_adapter.py b/Products/CMFPlone/controlpanel/tests/test_controlpanel_bbb_language_adapter.py
--- a/Products/CMFPlone/controlpanel/tests/test_controlpanel_bbb_language_adapter.py
+++ b/Products/CMFPlone/controlpanel/tests/test_controlpanel_bbb_language_adapter.py
@@ -74,24 +74,24 @@ def test_get_use_combined_language_codes(self):
         self.assertEqual(
             getAdapter(
                 self.portal, ILanguageSchema).use_combined_language_codes,
-            False
+            True
         )
-        self.settings.use_combined_language_codes = True
+        self.settings.use_combined_language_codes = False
         self.assertEquals(
             getAdapter(self.portal, ILanguageSchema).use_combined_language_codes,
-            True
+            False
         )
 
     def test_set_use_combined_language_codes(self):
         self.assertEquals(
             self.settings.use_combined_language_codes,
-            False
+            True
         )
         getAdapter(
-              self.portal, ILanguageSchema).use_combined_language_codes = True
+              self.portal, ILanguageSchema).use_combined_language_codes = False
         self.assertEquals(
             self.settings.use_combined_language_codes,
-            True
+            False
         )
 
     def test_get_display_flags(self):
diff --git a/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_language.py b/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_language.py
--- a/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_language.py
+++ b/Products/CMFPlone/controlpanel/tests/test_controlpanel_browser_language.py
@@ -108,25 +108,26 @@ def test_default_language(self):
     #     self.assertEqual(settings.available_languages, ['en', 'de'])
 
     def test_use_combined_language_codes(self):
+        """This checks swithing combined languages codes support off/on."""
         registry = getUtility(IRegistry)
         settings = registry.forInterface(ILanguageSchema, prefix='plone')
         self.browser.open(
             "%s/@@language-controlpanel" % self.portal_url)
-        self.assertEqual(settings.use_combined_language_codes, False)
+        self.assertEqual(settings.use_combined_language_codes, True)
         self.assertEqual(
             self.browser.getControl(
                 'Show country-specific language variants'
             ).selected,
-            False
+            True
         )
         self.browser.getControl(
             'Show country-specific language variants'
-        ).selected = True
+        ).selected = False
 
         self._inject_available_languages_field('en')
         self.browser.getControl('Save').click()
 
-        self.assertEqual(settings.use_combined_language_codes, True)
+        self.assertEqual(settings.use_combined_language_codes, False)
 
     def test_display_flags(self):
         registry = getUtility(IRegistry)