mirror of
https://github.com/django/django.git
synced 2025-09-15 13:39:11 +00:00
magic-removal: Merged to [2056]
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2057 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a4ead45cb2
commit
58605bcfe3
@ -4,6 +4,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
|
def compile_messages():
|
||||||
basedir = None
|
basedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
@ -22,3 +23,5 @@ for (dirpath, dirnames, filenames) in os.walk(basedir):
|
|||||||
cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf)
|
cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
compile_messages()
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from django.utils.translation import templateize
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
from django.utils.translation import templateize
|
|
||||||
|
|
||||||
pythonize_re = re.compile(r'\n\s*//')
|
pythonize_re = re.compile(r'\n\s*//')
|
||||||
|
|
||||||
|
def make_messages():
|
||||||
localedir = None
|
localedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
@ -137,3 +137,5 @@ for lang in languages:
|
|||||||
open(pofile, 'wb').write(msgs)
|
open(pofile, 'wb').write(msgs)
|
||||||
os.unlink(potfile)
|
os.unlink(potfile)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
make_messages()
|
||||||
|
@ -4,6 +4,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
|
def unique_messages():
|
||||||
basedir = None
|
basedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
@ -24,3 +25,5 @@ for (dirpath, dirnames, filenames) in os.walk(basedir):
|
|||||||
msg = stdout.read()
|
msg = stdout.read()
|
||||||
open('%s.po' % pf, 'w').write(msg)
|
open('%s.po' % pf, 'w').write(msg)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unique_messages()
|
||||||
|
@ -447,6 +447,24 @@ Notes:
|
|||||||
en-us).
|
en-us).
|
||||||
|
|
||||||
.. _LANGUAGES setting: http://www.djangoproject.com/documentation/settings/#languages
|
.. _LANGUAGES setting: http://www.djangoproject.com/documentation/settings/#languages
|
||||||
|
* the LocaleMiddleware can only select languages for which there is a
|
||||||
|
django provided base translation. If you want to provide translations
|
||||||
|
for your application that aren't already in the set of translations
|
||||||
|
in Djangos source tree, you will want to at least provide basic
|
||||||
|
translations for that language. For example Django uses technical
|
||||||
|
message IDs to translate date formats and time formats - so you will
|
||||||
|
need at least those translations for the system to work correctly.
|
||||||
|
|
||||||
|
A good starting point is to just copy over the english ``.po`` file
|
||||||
|
and to translate at least the technical messages and maybe the validator
|
||||||
|
messages, too.
|
||||||
|
|
||||||
|
Technical message IDs are easily recognized by them being all upper case.
|
||||||
|
You don't translate the message ID as with other messages, you provide
|
||||||
|
the correct local variant on the provided english value. For example with
|
||||||
|
``DATETIME_FORMAT`` (or ``DATE_FORMAT`` or ``TIME_FORMAT``), this would
|
||||||
|
be the format string that you want to use in your language. The format
|
||||||
|
is identical to the ``now`` tag date formattings.
|
||||||
|
|
||||||
Once ``LocaleMiddleware`` determines the user's preference, it makes this
|
Once ``LocaleMiddleware`` determines the user's preference, it makes this
|
||||||
preference available as ``request.LANGUAGE_CODE`` for each `request object`_.
|
preference available as ``request.LANGUAGE_CODE`` for each `request object`_.
|
||||||
|
@ -285,7 +285,7 @@ optional, third positional argument, ``processors``. In this example, the
|
|||||||
Here's what each of the default processors does:
|
Here's what each of the default processors does:
|
||||||
|
|
||||||
.. _HttpRequest object: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
|
.. _HttpRequest object: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
|
||||||
.. _TEMPLATE_CONTEXT_PROCESSORS setting: http://www.djangoproject.com/documentation/settings/#template-context_processors
|
.. _TEMPLATE_CONTEXT_PROCESSORS setting: http://www.djangoproject.com/documentation/settings/#template-context-processors
|
||||||
|
|
||||||
django.core.context_processors.auth
|
django.core.context_processors.auth
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Loading…
x
Reference in New Issue
Block a user