dev.rst 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Babel Development
  2. =================
  3. Babel as a library has a long history that goes back to the Trac project.
  4. Since then it has evolved into an independently developed project that
  5. implements data access for the CLDR project.
  6. This document tries to explain as best as possible the general rules of
  7. the project in case you want to help out developing.
  8. Tracking the CLDR
  9. -----------------
  10. Generally the goal of the project is to work as closely as possible with
  11. the CLDR data. This has in the past caused some frustrating problems
  12. because the data is entirely out of our hand. To minimize the frustration
  13. we generally deal with CLDR updates the following way:
  14. * bump the CLDR data only with a major release of Babel.
  15. * never perform custom bugfixes on the CLDR data.
  16. * never work around CLDR bugs within Babel. If you find a problem in
  17. the data, report it upstream.
  18. * adjust the parsing of the data as soon as possible, otherwise this
  19. will spiral out of control later. This is especially the case for
  20. bigger updates that change pluralization and more.
  21. * try not to test against specific CLDR data that is likely to change.
  22. Python Versions
  23. ---------------
  24. At the moment the following Python versions should be supported:
  25. * Python 2.7
  26. * Python 3.4 and up
  27. * PyPy tracking 2.7 and 3.2 and up
  28. While PyPy does not currently support 3.3, it does support traditional
  29. unicode literals which simplifies the entire situation tremendously.
  30. Documentation must build on Python 2, Python 3 support for the
  31. documentation is an optional goal. Code examples in the docs preferably
  32. are written in a style that makes them work on both 2.x and 3.x with
  33. preference to the former.
  34. Unicode
  35. -------
  36. Unicode is a big deal in Babel. Here is how the rules are set up:
  37. * internally everything is unicode that makes sense to have as unicode.
  38. The exception to this rule are things which on Python 2 traditionally
  39. have been bytes. For example file names on Python 2 should be treated
  40. as bytes wherever possible.
  41. * Encode / decode at boundaries explicitly. Never assume an encoding in
  42. a way it cannot be overridden. utf-8 should be generally considered
  43. the default encoding.
  44. * Dot not use ``unicode_literals``, instead use the ``u''`` string
  45. syntax. The reason for this is that the former introduces countless
  46. of unicode problems by accidentally upgrading strings to unicode which
  47. should not be. (docstrings for instance).
  48. Dates and Timezones
  49. -------------------
  50. Generally all timezone support in Babel is based on pytz which it just
  51. depends on. Babel should assume that timezone objects are pytz based
  52. because those are the only ones with an API that actually work correctly
  53. (due to the API problems with non UTC based timezones).
  54. Assumptions to make:
  55. * use UTC where possible.
  56. * be super careful with local time. Do not use local time without
  57. knowing the exact timezone.
  58. * `time` without date is a very useless construct. Do not try to
  59. support timezones for it. If you do, assume that the current local
  60. date is assumed and not utc date.