changeset 131:1738cbba372c

new cfg settings: language_ignore_browser and language_default (was: default_lang) imported from: moin--main--1.5--patch-133
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 23 Oct 2005 12:02:20 +0000
parents d3a28c683d8f
children 88acc9c18b90
files MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/i18n/__init__.py MoinMoin/multiconfig.py MoinMoin/request.py MoinMoin/scripts/repair_language.py MoinMoin/wikiaction.py docs/CHANGES docs/CHANGES.config
diffstat 9 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/PageEditor.py	Sun Oct 23 12:02:20 2005 +0000
@@ -373,7 +373,7 @@
         # TODO: currently self.language is None at this point. We have
         # to do processing instructions parsing earlier, or move page
         # language into meta file.
-        lang = self.language or self.request.cfg.default_lang
+        lang = self.language or self.request.cfg.language_default
 
         # to prevent moving away from the page without saving it
         self.request.write(u'''\
--- a/MoinMoin/PageGraphicalEditor.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/PageGraphicalEditor.py	Sun Oct 23 12:02:20 2005 +0000
@@ -253,7 +253,7 @@
         # TODO: currently self.language is None at this point. We have
         # to do processing instructions parsing earlier, or move page
         # language into meta file.
-        lang = self.language or self.request.cfg.default_lang
+        lang = self.language or self.request.cfg.language_default
         contentlangdirection = i18n.getDirection(lang) # 'ltr' or 'rtl'
         uilanguage = self.request.lang
         url_prefix = self.request.cfg.url_prefix
--- a/MoinMoin/i18n/__init__.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/i18n/__init__.py	Sun Oct 23 12:02:20 2005 +0000
@@ -199,15 +199,16 @@
     # Or try to return one of the user browser accepted languages, if it
     # is available on this wiki...
     available = wikiLanguages()
-    for lang in browserLanguages(request):
-        if available.has_key(lang):
-            if request.http_accept_language:
-                request.setHttpHeader('Vary: Accept-Language')
-            return lang
+    if not request.cfg.language_ignore_browser:
+        for lang in browserLanguages(request):
+            if available.has_key(lang):
+                if request.http_accept_language:
+                    request.setHttpHeader('Vary: Accept-Language')
+                return lang
     
     # Or return the wiki default language...
-    if available.has_key(request.cfg.default_lang):
-        lang = request.cfg.default_lang
+    if available.has_key(request.cfg.language_default):
+        lang = request.cfg.language_default
 
     # If everything else fails, read the manual... or return 'en'
     else:
--- a/MoinMoin/multiconfig.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/multiconfig.py	Sun Oct 23 12:02:20 2005 +0000
@@ -201,7 +201,6 @@
     data_underlay_dir = './underlay/'
     date_fmt = '%Y-%m-%d'
     datetime_fmt = '%Y-%m-%d %H:%M:%S'
-    default_lang = 'en'
     default_markup = 'wiki'
     docbook_html_dir = r"/usr/share/xml/docbook/stylesheet/nwalsh/html/" # correct for debian sarge
     editor_default = 'text' # which editor is called when nothing is specified
@@ -228,6 +227,10 @@
 
     interwiki_preferred = [] # list of wiki names to show at top of interwiki list
 
+    language_default = 'en'
+    language_ignore_browser = False # ignore browser settings, use language_default
+                                    # or user prefs
+
     lupy_search = False # disabled until lupy is finished
 
     mail_login = None # or "user pwd" if you need to use SMTP AUTH
@@ -424,7 +427,7 @@
         self._fillDicts()
         
         # Normalize values
-        self.default_lang = self.default_lang.lower()
+        self.language_default = self.language_default.lower()
 
         # Use site name as default name-logo
         if self.logo_string is None:
--- a/MoinMoin/request.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/request.py	Sun Oct 23 12:02:20 2005 +0000
@@ -159,7 +159,7 @@
             # Language for content. Page content should use the wiki
             # default lang, but generated content like search results
             # should use the user language.
-            self.content_lang = self.cfg.default_lang
+            self.content_lang = self.cfg.language_default
             self.getText = lambda text, i18n=self.i18n, request=self, lang=self.lang, **kv: i18n.getText(text, request, lang, kv.get('formatted', True))
 
             self.opened_logs = 0
@@ -446,7 +446,7 @@
         # This is the content language and has nothing to do with
         # The user interface language. The content language can change
         # during the rendering of a page by lang macros
-        self.current_lang = self.cfg.default_lang
+        self.current_lang = self.cfg.language_default
 
         self._footer_fragments = {}
         self._all_pages = None
--- a/MoinMoin/scripts/repair_language.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/scripts/repair_language.py	Sun Oct 23 12:02:20 2005 +0000
@@ -30,7 +30,7 @@
 
     In patch-325 a new #language processing instruction has been added.
     Pages that specify the language with it are displayed using correct
-    direction, even if default_lang use different direction.
+    direction, even if language_default use different direction.
 
     In the past, pages used to have ##language:xx comment. This comment
     has no effect, and should be replaced with newer #language xx
--- a/MoinMoin/wikiaction.py	Sun Oct 23 10:57:09 2005 +0000
+++ b/MoinMoin/wikiaction.py	Sun Oct 23 12:02:20 2005 +0000
@@ -392,7 +392,7 @@
     # This action uses page or wiki language TODO: currently
     # page.language is broken and not available now, when we fix it,
     # this will be automatically fixed.
-    lang = page.language or request.cfg.default_lang
+    lang = page.language or request.cfg.language_default
     request.setContentLanguage(lang)
     
     wikiutil.send_title(request, _('Info for "%s"') % (title,), pagename=pagename)
--- a/docs/CHANGES	Sun Oct 23 10:57:09 2005 +0000
+++ b/docs/CHANGES	Sun Oct 23 12:02:20 2005 +0000
@@ -31,6 +31,11 @@
       * cfg.mail_sendmail = "/usr/sbin/sendmail -t -i" can be used if sending
         via SMTP doesn't work on your server. Default is None and that means
         using SMTP.
+      * language_default replaces the old default_lang setting (just renamed).
+      * language_ignore_browser = True can be used to let moin ignore the
+        user's browser settings (e.g. if you run a local-language only wiki
+        and your users use misconfigured or buggy browsers often). Default is
+        False. Don't forget to set language_default when using this.
  
     * Wiki Editor changes / new WYSIWYG editor
      * fully imported the javascript based LGPLed FCKeditor (many thanks
--- a/docs/CHANGES.config	Sun Oct 23 10:57:09 2005 +0000
+++ b/docs/CHANGES.config	Sun Oct 23 12:02:20 2005 +0000
@@ -14,6 +14,9 @@
                #   if cfg.hacks.get('feature', False): <doit>
                # A non-existing hack key should ever mean False, None, "", [] or {}!
     interwiki_preferred = [] # list of wiki names to show at top of interwiki list
+    language_default = 'en'
+    language_ignore_browser = False # ignore browser settings, use language_default
+                                    # or user prefs
     lupy_search = False # disabled until lupy is finished
     mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
     superuser = [] # list of unicode user names that have super powers :)