django-js-catalog.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Empty Django 1.7 JS Catalog
  2. (function (globals) {
  3. var django = globals.django || (globals.django = {});
  4. django.pluralidx = function (count) { return (count == 1) ? 0 : 1; };
  5. /* gettext identity library */
  6. django.gettext = function (msgid) { return msgid; };
  7. django.ngettext = function (singular, plural, count) { return (count == 1) ? singular : plural; };
  8. django.gettext_noop = function (msgid) { return msgid; };
  9. django.pgettext = function (context, msgid) { return msgid; };
  10. django.npgettext = function (context, singular, plural, count) { return (count == 1) ? singular : plural; };
  11. django.interpolate = function (fmt, obj, named) {
  12. if (named) {
  13. return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
  14. } else {
  15. return fmt.replace(/%s/g, function(match){return String(obj.shift())});
  16. }
  17. };
  18. /* formatting library */
  19. django.formats = {
  20. "DATETIME_FORMAT": "N j, Y, P",
  21. "DATETIME_INPUT_FORMATS": [
  22. "%Y-%m-%d %H:%M:%S",
  23. "%Y-%m-%d %H:%M:%S.%f",
  24. "%Y-%m-%d %H:%M",
  25. "%Y-%m-%d",
  26. "%m/%d/%Y %H:%M:%S",
  27. "%m/%d/%Y %H:%M:%S.%f",
  28. "%m/%d/%Y %H:%M",
  29. "%m/%d/%Y",
  30. "%m/%d/%y %H:%M:%S",
  31. "%m/%d/%y %H:%M:%S.%f",
  32. "%m/%d/%y %H:%M",
  33. "%m/%d/%y"
  34. ],
  35. "DATE_FORMAT": "N j, Y",
  36. "DATE_INPUT_FORMATS": [
  37. "%Y-%m-%d",
  38. "%m/%d/%Y",
  39. "%m/%d/%y"
  40. ],
  41. "DECIMAL_SEPARATOR": ".",
  42. "FIRST_DAY_OF_WEEK": "0",
  43. "MONTH_DAY_FORMAT": "F j",
  44. "NUMBER_GROUPING": "3",
  45. "SHORT_DATETIME_FORMAT": "m/d/Y P",
  46. "SHORT_DATE_FORMAT": "m/d/Y",
  47. "THOUSAND_SEPARATOR": ",",
  48. "TIME_FORMAT": "P",
  49. "TIME_INPUT_FORMATS": [
  50. "%H:%M:%S",
  51. "%H:%M:%S.%f",
  52. "%H:%M"
  53. ],
  54. "YEAR_MONTH_FORMAT": "F Y"
  55. };
  56. django.get_format = function (format_type) {
  57. var value = django.formats[format_type];
  58. if (typeof(value) == 'undefined') {
  59. return format_type;
  60. } else {
  61. return value;
  62. }
  63. };
  64. /* add to global namespace */
  65. globals.pluralidx = django.pluralidx;
  66. globals.gettext = django.gettext;
  67. globals.ngettext = django.ngettext;
  68. globals.gettext_noop = django.gettext_noop;
  69. globals.pgettext = django.pgettext;
  70. globals.npgettext = django.npgettext;
  71. globals.interpolate = django.interpolate;
  72. globals.get_format = django.get_format;
  73. }(this));