diff -r f0b754562bac django/conf/global_settings.py
--- a/django/conf/global_settings.py	Sun Feb 03 06:54:26 2008 -0200
+++ b/django/conf/global_settings.py	Tue Feb 05 00:42:09 2008 -0200
@@ -47,7 +47,7 @@ LANGUAGES = (
     ('el', gettext_noop('Greek')),
     ('en', gettext_noop('English')),
     ('es', gettext_noop('Spanish')),
-    ('es_AR', gettext_noop('Argentinean Spanish')),
+    ('es-ar', gettext_noop('Argentinean Spanish')),
     ('fa', gettext_noop('Persian')),
     ('fi', gettext_noop('Finnish')),
     ('fr', gettext_noop('French')),
diff -r f0b754562bac django/utils/translation/trans_real.py
--- a/django/utils/translation/trans_real.py	Sun Feb 03 06:54:26 2008 -0200
+++ b/django/utils/translation/trans_real.py	Tue Feb 05 00:42:09 2008 -0200
@@ -357,8 +357,8 @@ def get_language_from_request(request):
         return lang_code
 
     accept = request.META.get('HTTP_ACCEPT_LANGUAGE', '')
-    for lang, unused in parse_accept_lang_header(accept):
-        if lang == '*':
+    for accept_lang, unused in parse_accept_lang_header(accept):
+        if accept_lang == '*':
             break
 
         # We have a very restricted form for our language files (no encoding
@@ -366,7 +366,7 @@ def get_language_from_request(request):
         # language each time. So we avoid the overhead of gettext.find() and
         # look up the MO file manually.
 
-        normalized = locale.locale_alias.get(to_locale(lang, True))
+        normalized = locale.locale_alias.get(to_locale(accept_lang, True))
         if not normalized:
             continue
 
@@ -378,10 +378,11 @@ def get_language_from_request(request):
             # need to check again.
             return _accepted[normalized]
 
-        for lang in (normalized, normalized.split('_')[0]):
+        for lang in (accept_lang, accept_lang.split('-')[0]):
             if lang not in supported:
                 continue
-            langfile = os.path.join(globalpath, lang, 'LC_MESSAGES',
+            normalized = locale.locale_alias.get(to_locale(lang, True)).split('.')[0]
+            langfile = os.path.join(globalpath, normalized, 'LC_MESSAGES',
                     'django.mo')
             if os.path.exists(langfile):
                 _accepted[normalized] = lang
diff -r f0b754562bac tests/regressiontests/i18n/misc.py
--- a/tests/regressiontests/i18n/misc.py	Sun Feb 03 06:54:26 2008 -0200
+++ b/tests/regressiontests/i18n/misc.py	Tue Feb 05 00:42:09 2008 -0200
@@ -54,4 +54,41 @@ Bad headers; should always return [].
 >>> p('')
 []
 
+>>> from django.utils.translation.trans_real import get_language_from_request
+>>> g = get_language_from_request
+>>> from django.http import HttpRequest
+>>> r = HttpRequest
+>>> r.COOKIES = {}
+
+These tests assumes the es, es_AR, pt and pt_BR translations aren't going to
+be deleted from the Django source tree.
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt-br'}
+>>> g(r)
+'pt-br'
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt'}
+>>> g(r)
+'pt'
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es,de'}
+>>> g(r)
+'es'
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-ar,de'}
+>>> g(r)
+'es-ar'
+
+This test assumes there won't be a Django translation to a US variation
+of the Spanish language, a safe assumption. When the user sets it
+as the preferred language, the main 'es' translation should be selected
+instead.
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'es-us'}
+>>> g(r)
+'es'
+
+This tests the following scenario: there isn't a main language (zh)
+translation of Django but there is a translation to variation (zh_CN)
+the user sets zh-cn as the preferred language, it should be selected by
+Django without falling back nor ignoring it.
+>>> r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'}
+>>> g(r)
+'zh-cn'
+
 """
