Commit a2ce3b74 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make sure that languages are sorted, regardless of the order of language...

Make sure that languages are sorted, regardless of the order of language additions. This fixes the problem that LANG-SCRIPT (e.g. ja-kana) is accidentally selected instead of LANG (e.g. ja), because itools gives the same score to both, and when multiple codes have the same score, itools just selects the first one of a language list. So, with this change, LANG is always defined before LANG-SCRIPT, thus LANG is selected.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36426 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d7f761d1
...@@ -209,6 +209,17 @@ def _del_user_defined_language(self, language_code): ...@@ -209,6 +209,17 @@ def _del_user_defined_language(self, language_code):
self.user_defined_languages = tuple(user_defined_languages) self.user_defined_languages = tuple(user_defined_languages)
self._p_changed = True self._p_changed = True
# Override add_language so that languages are always sorted.
# Otherwise, selected languages can be nearly random.
def add_language(self, language):
"""
Adds a new language.
"""
if language not in self._languages:
new_language_list = tuple(self._languages) + (language,)
new_language_list = tuple(sorted(new_language_list))
self._languages = new_language_list
from Products.Localizer import LanguageManager from Products.Localizer import LanguageManager
LanguageManager.LanguageManager.get_languages_mapping = get_languages_mapping LanguageManager.LanguageManager.get_languages_mapping = get_languages_mapping
LanguageManager.LanguageManager.get_language_name = get_language_name LanguageManager.LanguageManager.get_language_name = get_language_name
...@@ -217,6 +228,7 @@ LanguageManager.LanguageManager.get_user_defined_language_name = get_user_define ...@@ -217,6 +228,7 @@ LanguageManager.LanguageManager.get_user_defined_language_name = get_user_define
LanguageManager.LanguageManager.get_user_defined_languages = get_user_defined_languages LanguageManager.LanguageManager.get_user_defined_languages = get_user_defined_languages
LanguageManager.LanguageManager._add_user_defined_language = _add_user_defined_language LanguageManager.LanguageManager._add_user_defined_language = _add_user_defined_language
LanguageManager.LanguageManager._del_user_defined_language = _del_user_defined_language LanguageManager.LanguageManager._del_user_defined_language = _del_user_defined_language
LanguageManager.LanguageManager.add_language = add_language
LanguageManager.InitializeClass(LanguageManager.LanguageManager) LanguageManager.InitializeClass(LanguageManager.LanguageManager)
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment