prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Broken URL for jquery.ui.datepicker when 'en-US' used as lang 
  This isn't a big deal at all, but wanted to post just in case anyone wants to take a look.
  
  When loading a page with `jquery.ui.datepicker.js`, I notice in console that a call to http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-en-US.js returns a 404.
  
  I searched out the CDN for the directory in which the file is attempting to be called:
  http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/
  
  As you can see, there is no `../jquery.ui.datepicker-en-US.js` present (not that there necessarily ought to be)
  
  The call stems from:
  https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/templatetags/localize.py#L42
  
  The interpolation inserts `en-US` into the URI
  
  Again, no big deal... just FYI
  
  Cheers, all!
  
  Edit:
  
  I should add, this issue does _not_ break usability - a fallback seems to be in place.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/wagtailadmin/templatetags/localize.py`
  Content:
  ```
  1 from django import template
  2 from django.conf import settings
  3 from django.utils import formats
  4 from django.utils.translation import get_language
  5 
  6 register = template.Library()
  7 
  8 # For reasons unkown, the el (greek) locale in django/conf/locale/el/formats.py 
  9 # *did not* contain a DATE_INPUT_FORMATS -- so it fell back to using the US 
  10 # date format (mm/dd/yy) which is not the correct one for Greece (dd/mm/yy). 
  11 # This means that if we used a localized datepicker django *won't* be able to
  12 # parse the dates! So a test here checks if DATE_INPUT_FORMATS is actually 
  13 # defined in a format module. If yes then it will just return an empty string 
  14 # so that the normal, localized date format from datepicker will be used.
  15 # If DATE_INPUT_FORMATS is not defined then it will return
  16 @register.assignment_tag
  17 def get_date_format_override():
  18     if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True:
  19         
  20         for m in formats.get_format_modules():
  21             if hasattr(m, 'DATE_INPUT_FORMATS'):
  22                 return ''
  23             else: # fall back to the ISO to be sure date will be parsed
  24                 return 'yy-mm-dd'
  25     else: # Fall back to ISO if I18N is *not* used
  26         return 'yy-mm-dd'
  27 
  28 # Get the correct i18n + l10n settings for datepicker depending on current 
  29 # thread language  
  30 @register.simple_tag
  31 def get_localized_datepicker_js():
  32     if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True and \
  33         hasattr(settings, 'USE_L10N') and settings.USE_L10N==True:
  34         
  35         lang  = get_language()
  36         
  37         if '-' in lang:
  38             lang_parts = lang.split('-')
  39             lang = lang_parts[0].lower() +'-'+ lang_parts[1].upper()
  40         else:
  41             lang=lang.lower()
  42         return '<script src="//jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-{0}.js"></script>'.format(
  43             lang
  44         )
  45         
  46     else: # Don't write anything if we don't use I18N and L10N
  47         return ''        
  48
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/wagtail/wagtailadmin/templatetags/localize.py b/wagtail/wagtailadmin/templatetags/localize.py
  --- a/wagtail/wagtailadmin/templatetags/localize.py
  +++ b/wagtail/wagtailadmin/templatetags/localize.py
  @@ -1,5 +1,6 @@
   from django import template
   from django.conf import settings
  +from django.templatetags.static import static
   from django.utils import formats
   from django.utils.translation import get_language
   
  @@ -25,6 +26,15 @@
       else: # Fall back to ISO if I18N is *not* used
           return 'yy-mm-dd'
   
  +# This is a list of all supported langs for jquery-ui datepicker which exist in
  +# wagtailadmin/js/venor/i18n/. In case any new translations are added there the
  +# language code should also be added in this list.
  +SUPPORTED_DATEPICKER_LANGS = ['af', 'ar-DZ', 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'cy-GB', 'da', 'de',
  +    'el', 'en-AU', 'en-GB', 'en-NZ', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-CA', 'fr-CH', 'fr', 'gl',
  +    'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'ko', 'ky', 'lb', 'lt', 'lv',
  +    'mk', 'ml', 'ms', 'nb', 'nl-BE', 'nl', 'nn', 'no', 'pl', 'pt-BR', 'pt', 'rm', 'ro', 'ru', 'sk', 'sl', 'sq',
  +    'sr-SR', 'sr', 'sv', 'ta', 'th', 'tj', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW'
  +]
   # Get the correct i18n + l10n settings for datepicker depending on current 
   # thread language  
   @register.simple_tag
  @@ -39,10 +49,14 @@
               lang = lang_parts[0].lower() +'-'+ lang_parts[1].upper()
           else:
               lang=lang.lower()
  -        return '<script src="//jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-{0}.js"></script>'.format(
  -            lang
  -        )
  +        if lang in SUPPORTED_DATEPICKER_LANGS:
  +            translation_file = static("wagtailadmin/js/vendor/i18n/jquery.ui.datepicker-{0}.js".format(
  +                lang
  +            ))
  +            return '<script src="{0}"></script>'.format(translation_file)
  +        else: # Don't return anything if language is not supported
  +            return ''
           
  -    else: # Don't write anything if we don't use I18N and L10N
  +    else: # Don't return anything if we don't use I18N and L10N
           return ''        
           
  \ No newline at end of file
  
verification_info: {"golden_diff": "diff --git a/wagtail/wagtailadmin/templatetags/localize.py b/wagtail/wagtailadmin/templatetags/localize.py\n--- a/wagtail/wagtailadmin/templatetags/localize.py\n+++ b/wagtail/wagtailadmin/templatetags/localize.py\n@@ -1,5 +1,6 @@\n from django import template\n from django.conf import settings\n+from django.templatetags.static import static\n from django.utils import formats\n from django.utils.translation import get_language\n \n@@ -25,6 +26,15 @@\n     else: # Fall back to ISO if I18N is *not* used\n         return 'yy-mm-dd'\n \n+# This is a list of all supported langs for jquery-ui datepicker which exist in\n+# wagtailadmin/js/venor/i18n/. In case any new translations are added there the\n+# language code should also be added in this list.\n+SUPPORTED_DATEPICKER_LANGS = ['af', 'ar-DZ', 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'cy-GB', 'da', 'de',\n+    'el', 'en-AU', 'en-GB', 'en-NZ', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-CA', 'fr-CH', 'fr', 'gl',\n+    'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'ko', 'ky', 'lb', 'lt', 'lv',\n+    'mk', 'ml', 'ms', 'nb', 'nl-BE', 'nl', 'nn', 'no', 'pl', 'pt-BR', 'pt', 'rm', 'ro', 'ru', 'sk', 'sl', 'sq',\n+    'sr-SR', 'sr', 'sv', 'ta', 'th', 'tj', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW'\n+]\n # Get the correct i18n + l10n settings for datepicker depending on current \n # thread language  \n @register.simple_tag\n@@ -39,10 +49,14 @@\n             lang = lang_parts[0].lower() +'-'+ lang_parts[1].upper()\n         else:\n             lang=lang.lower()\n-        return '<script src=\"//jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-{0}.js\"></script>'.format(\n-            lang\n-        )\n+        if lang in SUPPORTED_DATEPICKER_LANGS:\n+            translation_file = static(\"wagtailadmin/js/vendor/i18n/jquery.ui.datepicker-{0}.js\".format(\n+                lang\n+            ))\n+            return '<script src=\"{0}\"></script>'.format(translation_file)\n+        else: # Don't return anything if language is not supported\n+            return ''\n         \n-    else: # Don't write anything if we don't use I18N and L10N\n+    else: # Don't return anything if we don't use I18N and L10N\n         return ''        \n         \n\\ No newline at end of file\n", "issue": "Broken URL for jquery.ui.datepicker when 'en-US' used as lang \nThis isn't a big deal at all, but wanted to post just in case anyone wants to take a look.\n\nWhen loading a page with `jquery.ui.datepicker.js`, I notice in console that a call to http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-en-US.js returns a 404.\n\nI searched out the CDN for the directory in which the file is attempting to be called:\nhttp://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/\n\nAs you can see, there is no `../jquery.ui.datepicker-en-US.js` present (not that there necessarily ought to be)\n\nThe call stems from:\nhttps://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/templatetags/localize.py#L42\n\nThe interpolation inserts `en-US` into the URI\n\nAgain, no big deal... just FYI\n\nCheers, all!\n\nEdit:\n\nI should add, this issue does _not_ break usability - a fallback seems to be in place.\n\n", "before_files": [{"content": "from django import template\nfrom django.conf import settings\nfrom django.utils import formats\nfrom django.utils.translation import get_language\n\nregister = template.Library()\n\n# For reasons unkown, the el (greek) locale in django/conf/locale/el/formats.py \n# *did not* contain a DATE_INPUT_FORMATS -- so it fell back to using the US \n# date format (mm/dd/yy) which is not the correct one for Greece (dd/mm/yy). \n# This means that if we used a localized datepicker django *won't* be able to\n# parse the dates! So a test here checks if DATE_INPUT_FORMATS is actually \n# defined in a format module. If yes then it will just return an empty string \n# so that the normal, localized date format from datepicker will be used.\n# If DATE_INPUT_FORMATS is not defined then it will return\n@register.assignment_tag\ndef get_date_format_override():\n    if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True:\n        \n        for m in formats.get_format_modules():\n            if hasattr(m, 'DATE_INPUT_FORMATS'):\n                return ''\n            else: # fall back to the ISO to be sure date will be parsed\n                return 'yy-mm-dd'\n    else: # Fall back to ISO if I18N is *not* used\n        return 'yy-mm-dd'\n\n# Get the correct i18n + l10n settings for datepicker depending on current \n# thread language  \n@register.simple_tag\ndef get_localized_datepicker_js():\n    if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True and \\\n        hasattr(settings, 'USE_L10N') and settings.USE_L10N==True:\n        \n        lang  = get_language()\n        \n        if '-' in lang:\n            lang_parts = lang.split('-')\n            lang = lang_parts[0].lower() +'-'+ lang_parts[1].upper()\n        else:\n            lang=lang.lower()\n        return '<script src=\"//jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-{0}.js\"></script>'.format(\n            lang\n        )\n        \n    else: # Don't write anything if we don't use I18N and L10N\n        return ''        \n        ", "path": "wagtail/wagtailadmin/templatetags/localize.py"}], "after_files": [{"content": "from django import template\nfrom django.conf import settings\nfrom django.templatetags.static import static\nfrom django.utils import formats\nfrom django.utils.translation import get_language\n\nregister = template.Library()\n\n# For reasons unkown, the el (greek) locale in django/conf/locale/el/formats.py \n# *did not* contain a DATE_INPUT_FORMATS -- so it fell back to using the US \n# date format (mm/dd/yy) which is not the correct one for Greece (dd/mm/yy). \n# This means that if we used a localized datepicker django *won't* be able to\n# parse the dates! So a test here checks if DATE_INPUT_FORMATS is actually \n# defined in a format module. If yes then it will just return an empty string \n# so that the normal, localized date format from datepicker will be used.\n# If DATE_INPUT_FORMATS is not defined then it will return\n@register.assignment_tag\ndef get_date_format_override():\n    if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True:\n        \n        for m in formats.get_format_modules():\n            if hasattr(m, 'DATE_INPUT_FORMATS'):\n                return ''\n            else: # fall back to the ISO to be sure date will be parsed\n                return 'yy-mm-dd'\n    else: # Fall back to ISO if I18N is *not* used\n        return 'yy-mm-dd'\n\n# This is a list of all supported langs for jquery-ui datepicker which exist in\n# wagtailadmin/js/venor/i18n/. In case any new translations are added there the\n# language code should also be added in this list.\nSUPPORTED_DATEPICKER_LANGS = ['af', 'ar-DZ', 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'cy-GB', 'da', 'de',\n    'el', 'en-AU', 'en-GB', 'en-NZ', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-CA', 'fr-CH', 'fr', 'gl',\n    'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'ko', 'ky', 'lb', 'lt', 'lv',\n    'mk', 'ml', 'ms', 'nb', 'nl-BE', 'nl', 'nn', 'no', 'pl', 'pt-BR', 'pt', 'rm', 'ro', 'ru', 'sk', 'sl', 'sq',\n    'sr-SR', 'sr', 'sv', 'ta', 'th', 'tj', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW'\n]\n# Get the correct i18n + l10n settings for datepicker depending on current \n# thread language  \n@register.simple_tag\ndef get_localized_datepicker_js():\n    if hasattr(settings, 'USE_I18N') and settings.USE_I18N==True and \\\n        hasattr(settings, 'USE_L10N') and settings.USE_L10N==True:\n        \n        lang  = get_language()\n        \n        if '-' in lang:\n            lang_parts = lang.split('-')\n            lang = lang_parts[0].lower() +'-'+ lang_parts[1].upper()\n        else:\n            lang=lang.lower()\n        if lang in SUPPORTED_DATEPICKER_LANGS:\n            translation_file = static(\"wagtailadmin/js/vendor/i18n/jquery.ui.datepicker-{0}.js\".format(\n                lang\n            ))\n            return '<script src=\"{0}\"></script>'.format(translation_file)\n        else: # Don't return anything if language is not supported\n            return ''\n        \n    else: # Don't return anything if we don't use I18N and L10N\n        return ''        \n        ", "path": "wagtail/wagtailadmin/templatetags/localize.py"}]}