django-js-catalog.js 2.3 KB

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