Changeset 2060
- Timestamp:
- 01/18/06 19:09:28 (3 years ago)
- Files:
-
- django/branches/magic-removal/django/bin/compile-messages.py (modified) (1 diff)
- django/branches/magic-removal/django/bin/unique-messages.py (modified) (2 diffs)
- django/branches/magic-removal/django/utils/html.py (modified) (1 diff)
- django/branches/magic-removal/django/views/debug.py (modified) (1 diff)
- django/branches/magic-removal/django/views/i18n.py (modified) (3 diffs)
- django/branches/magic-removal/docs/i18n.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/bin/compile-messages.py
r2057 r2060 17 17 18 18 for (dirpath, dirnames, filenames) in os.walk(basedir): 19 for f ilein filenames:20 if f ile.endswith('.po'):21 sys.stderr.write('processing file %s in %s\n' % (f ile, dirpath))22 pf = os.path.splitext(os.path.join(dirpath, f ile))[0]19 for f in filenames: 20 if f.endswith('.po'): 21 sys.stderr.write('processing file %s in %s\n' % (f, dirpath)) 22 pf = os.path.splitext(os.path.join(dirpath, f))[0] 23 23 cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf) 24 24 os.system(cmd) django/branches/magic-removal/django/bin/unique-messages.py
r2057 r2060 3 3 import os 4 4 import sys 5 import getopt6 5 7 6 def unique_messages(): … … 17 16 18 17 for (dirpath, dirnames, filenames) in os.walk(basedir): 19 for f ilein filenames:20 if f ile.endswith('.po'):21 sys.stderr.write('processing file %s in %s\n' % (f ile, dirpath))22 pf = os.path.splitext(os.path.join(dirpath, f ile))[0]18 for f in filenames: 19 if f.endswith('.po'): 20 sys.stderr.write('processing file %s in %s\n' % (f, dirpath)) 21 pf = os.path.splitext(os.path.join(dirpath, f))[0] 23 22 cmd = 'msguniq "%s.po"' % pf 24 23 stdout = os.popen(cmd) django/branches/magic-removal/django/utils/html.py
r1972 r2060 13 13 word_split_re = re.compile(r'(\s+)') 14 14 punctuation_re = re.compile('^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$' % \ 15 ('|'.join([re.escape( p) for pin LEADING_PUNCTUATION]),16 '|'.join([re.escape( p) for pin TRAILING_PUNCTUATION])))15 ('|'.join([re.escape(x) for x in LEADING_PUNCTUATION]), 16 '|'.join([re.escape(x) for x in TRAILING_PUNCTUATION]))) 17 17 simple_email_re = re.compile(r'^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$') 18 18 link_target_attribute_re = re.compile(r'(<a [^>]*?)target=[^\s>]+') 19 19 html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) 20 hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape( d) for din DOTS]), re.DOTALL)20 hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL) 21 21 trailing_empty_content_re = re.compile(r'(?:<p>(?: |\s|<br \/>)*?</p>\s*)+\Z') 22 del x # Temporary variable 22 23 23 24 def escape(html): django/branches/magic-removal/django/views/debug.py
r1945 r2060 3 3 from django.utils.html import escape 4 4 from django.http import HttpResponseServerError, HttpResponseNotFound 5 import inspect, os, re, sys5 import os, re 6 6 from itertools import count, izip 7 7 from os.path import dirname, join as pathjoin django/branches/magic-removal/django/views/i18n.py
r1914 r2060 1 import re2 import os3 4 import gettext as gettext_module5 6 1 from django import http 7 2 from django.utils.translation import check_for_language, activate, to_locale, get_language 8 3 from django.utils.text import javascript_quote 9 4 from django.conf import settings 5 import os 6 import gettext as gettext_module 10 7 11 8 def set_language(request): … … 146 143 try: 147 144 catalog = gettext_module.translation(domain, path, [default_locale]) 148 except IOError , e:145 except IOError: 149 146 catalog = None 150 147 if catalog is not None: … … 155 152 try: 156 153 catalog = gettext_module.translation(domain, path, [locale]) 157 except IOError , e:154 except IOError: 158 155 catalog = None 159 156 if catalog is not None: django/branches/magic-removal/docs/i18n.txt
r2057 r2060 448 448 449 449 .. _LANGUAGES setting: http://www.djangoproject.com/documentation/settings/#languages 450 * the LocaleMiddlewarecan only select languages for which there is a451 djangoprovided base translation. If you want to provide translations450 * The ``LocaleMiddleware`` can only select languages for which there is a 451 Django-provided base translation. If you want to provide translations 452 452 for your application that aren't already in the set of translations 453 in Django s source tree, you will want to at least providebasic454 translations for that language. For example Django uses technical455 message IDs to translate date formats and time formats - so you will453 in Django's source tree, you'll want to provide at least basic 454 translations for that language. For example, Django uses technical 455 message IDs to translate date formats and time formats -- so you will 456 456 need at least those translations for the system to work correctly. 457 457 458 A good starting point is to just copy over the english ``.po`` file459 and to translate at least the technical messages andmaybe the validator458 A good starting point is to copy the English ``.po`` file and to 459 translate at least the technical messages -- maybe the validator 460 460 messages, too. 461 462 Technical message IDs are easily recognized by them being all upper case.463 You don't translate the message ID as with other messages, you provide464 the correct local variant on the provided english value. For examplewith461 462 Technical message IDs are easily recognized; they're all upper case. You 463 don't translate the message ID as with other messages, you provide the 464 correct local variant on the provided English value. For example, with 465 465 ``DATETIME_FORMAT`` (or ``DATE_FORMAT`` or ``TIME_FORMAT``), this would 466 be the format string that you want to use in your language. The format467 is identical to the ``now`` tag date formattings.466 be the format string that you want to use in your language. The format 467 is identical to the format strings used by the ``now`` template tag. 468 468 469 469 Once ``LocaleMiddleware`` determines the user's preference, it makes this
