Code

Changes between Version 22 and Version 23 of UnicodeBranch


Ignore:
Timestamp:
05/24/07 06:05:46 (7 years ago)
Author:
mtredinnick
Comment:

Tweaked the porting steps slightly.

Legend:

Unmodified
Added
Removed
Modified
  • UnicodeBranch

    v22 v23  
    5858One of the design goals of the Unicode branch is that very little significant changes to existing third-party code should be required. However, there are some things that developers should be aware of when writing applications designed to handle international input. 
    5959 
    60 A detailed list of things you might wish to think about when writing your code is in the unicode.txt file in the documentation directory. For the programmer on a deadline, here is the cheatsheet version (if you only use ASCII strings, none of these changes are necessary): 
     60A detailed list of things you might wish to think about when writing your code is in the {{{unicode.txt}}} file in the documentation directory. For the programmer on a deadline, here is the cheatsheet version (if you only use ASCII strings, none of these changes are necessary): 
    6161 
    6262 1. Change the {{{__str__}}} methods on your models to be {{{__unicode__}}} methods. Just change the name. Usually, nothing else will be needed. 
    6363 
    64  2. Look for any {{{str()}}} calls in your code that operate on model fields. These should almost always be changed to {{{smart_unicode()}}} calls (which is imported from {{{django.utils.encoding}}}). 
     64 2. Look for any {{{str()}}} calls in your code that operate on model fields. These should almost always be changed to {{{smart_unicode()}}} calls (which is imported from {{{django.utils.encoding}}}). In some cases, you may need to use {{{force_unicode()}}} (in the same module), but starting with a global change to {{{smart_unicode()}}} and then checking for problems is the "quick fix" way. (Details of the differences between the two functions are in {{{unicode.txt}}}.) 
    6565 
    6666 3. Use the unicode versions of the {{{django.utils.translation.*}}} functions. Replace {{{gettext}}} and {{{ngettext}}} with {{{ugettext}}} and {{{ungettext}}} respectively. There are also {{{ugettext_lazy}}} and {{{ungettext_lazy}}} functions if you use the lazy versions.