Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-25 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Stefan Wehrmeyer):

 I added a test case here:

 https://github.com/django/django/pull/11123

 I created the new `UnprefixedDefaultLanguageUtilsTests` based on the
 `UnprefixedDefaultLanguageTests` class (which is testing
 `LocaleMiddleware` behaviour on i18n URLs without prefix). All methods
 pass except `test_default_lang_without_prefix` ([https://djangoci.com/job
 /pull-requests-bionic/database=postgis,label=bionic-
 pr,python=python3.7/4322/testReport/ e.g. one test on DjangoCI]).

 This could be resolved by making the language detection of
 `LocaleMiddleware` and `get_language_from_request` behave the same way.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7fc30e74904aabf0f6e81280a637f808%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-24 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 OK, I'll re-open to have another look. (If you do have that test case,
 that would be super.)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.09d7ee5116dd3394c37c36f570aa8a17%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-23 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Stefan Wehrmeyer):

 Sorry, some more details about the use case.

 I'm running a Django CMS instance with their URLs included via
 `i18n_patterns` and `prefix_default_language=False`. I want the URL path
 to determine what language to serve (and `LocaleMiddleware` set this
 language correctly!).

 The problem is that Django CMS relies on `get_language_from_request`
 ([https://github.com/divio/django-
 cms/blob/eeb1e4712b3866e243daf800c142e2199e4be9df/cms/views.py#L85 e.g.
 here]) to detect which language to serve without the additional logic that
 is included in `LocaleMiddleware` to special case
 `prefix_default_language=False`.

 Example URLs with default language "en":
 - `/de/ueber/` – `LocaleMiddleware` sets "de", `get_language_from_request`
 with `check_path=True` returns "de"
 - `/about/` – `LocaleMiddleware` sets "en", `get_language_from_request`
 with `check_path=True` returns whatever is in session, language cookie or
 HTTP `Accept-Language` header, but should return "en" like
 `LocaleMiddleware`

 This leads in turn to the wrong language being served. This could
 certainly be solved in Django CMS as well.

 But currently there are cases when `LocaleMiddleware` will set a different
 language on the request than is returned by `get_language_from_request` –
 which makes this public API inconsistent IMHO.

 Thanks for taking the time to look into this. I can try to provide a test
 case if this makes it clearer.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.6f0b8f81edb173f7931fb5560f69dfdc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-23 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Carlton Gibson):

 Why wouldn't `get_language_from_path() or settings.LANGUAGE_CODE` do you?
 (Just trying to understand the use-case.)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.276ac17a5f3c55260ca3eedf5edbcee6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-23 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Stefan Wehrmeyer):

 Hey Carlton, thanks for reviewing.

 The problem with `get_language_from_request` is that the browser `Accept-
 Language` header is very likely set and will determine the language.
 However, I want the language to be determined by the path – even when
 `prefix_default_language=False`. This works with
 `prefix_default_language=True`.

 `LocaleMiddleware` actually does this, but does it around
 `get_language_from_request`:

 
https://github.com/django/django/blob/cbf7e71558c94ce1c327b683768a18a25d82d197/django/middleware/locale.py#L19-L24

 So maybe an idea could be to move these lines into
 `get_language_from_request` in order to make this logic available to other
 Django apps that rely on this API (in my case django cms). Not sure if
 this would be a backwards-incompatible change though.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.b33b494652b4e264b4bbecb0acd9167e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-22 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
-+-
 Reporter:  Stefan Wehrmeyer |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:   |  Version:  2.1
  Internationalization   |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi Stefan.

 I think this is intended behaviour: doing clever things, like falling back
 to the default `LANGUAGE_CODE` is out of scope for this function. It's job
 it just (literally) to get the language code from the path. If it's not
 there then `None` is the desired response.

 The more sophisticated `get_language_from_request()` will do the ''right
 thing'' here and, ultimately, return `settings.LANGUAGE_CODE` if nothing
 else preempts it.

 (Was there an incorrect behaviour you observed here, beyond this?)

 Thanks.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.096cac01ef5c1866803f8bacb673e0a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False

2019-03-20 Thread Django
#30272: get_language_from_path not respecting i18n_patterns
prefix_default_language=False
+
   Reporter:  Stefan Wehrmeyer  |  Owner:  nobody
   Type:  Bug   | Status:  new
  Component:  Internationalization  |Version:  2.1
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 Starting in Django 1.10 `django.conf.urls.i18n.i18n_patterns` accepts an
 option `prefix_default_language` that can be set to `False`. This adds no
 language prefix for the the default language when reversing URLs.

 `django.utils.translation.get_language_from_path` is supposed to detect
 the language from the URL path. At the moment it returns `None` when no
 language URL prefix is found. I would argue that if the path is resolved
 by `i18n_patterns` with `prefix_default_language=False`
 `get_language_from_path` should return the default language
 (`settings.LANGUAGE_CODE`)

 I believe the intention of using `i18n_patterns` and setting
 `prefix_default_language=False` is two-fold:
 - construct URLs in the default language without a language prefix (this
 works now)
 - detect non-prefixed URLs as using the default language (currently *not*
 working, falls back to session, cookie, HTTP headers)

 Let me know if you consider this a bug.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.4e5b3b4f0ca774a0e2287b10b2d5b1ea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.