GithubHelp home page GithubHelp logo

Comments (19)

mauricioabreu avatar mauricioabreu commented on July 29, 2024 1

@wagnerluis1982 not that I remember.
You are the best person to workn on this issue so... go ahead! :-)

If you need anything don't forget to ask here.

from speakerfight.

vmesel avatar vmesel commented on July 29, 2024

I think this issue is already solved, right @luanfonceca ?

from speakerfight.

luanfonceca avatar luanfonceca commented on July 29, 2024

Nope, we should have something in the User dropdown to change his language.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

Currently, the language is globally defined on settings.py, right?

How about to also make this automatically, by reading the Accept header of request? The user settings would still be the first place to see, but if wasn't set, the request info would be considered.

from speakerfight.

mauricioabreu avatar mauricioabreu commented on July 29, 2024

@wagnerluis1982 hmmm, it seems a bit complicated to solve the problem.
The feature does not payt the code and your efforts developing it. Also reading headers is not a good idea. Every browser does in its own way. What do you think?

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

@mauricioabreu what exactly is complicated? The user-defined idiom is what this issue is for. So in the main view (read by all pages) we would have something like:

idiom = user.get_idiom() or get_request_idiom(request)

from speakerfight.

mauricioabreu avatar mauricioabreu commented on July 29, 2024

@wagnerluis1982 parsing headers and trust them. I think that having the language avaible in the user settings is good enough. I am not against the idea but not sure if the efforts making this code will pay the feature.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

@mauricioabreu, I'm not really an expert in i18n, but I remembered that Django has a standard way to discover the language by request. And I found that is LocaleMiddleware.

The following link explains how this middleware works. According to what I read, it's only a matter of adding to MIDDLEWARE_CLASSES to work!

https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-django-discovers-language-preference

Of course this will not completely solve the problem, as the user can't override the browser idiom, but is a starting point.

from speakerfight.

mauricioabreu avatar mauricioabreu commented on July 29, 2024

@wagnerluis1982 now we are talking :P

The middleware can make it work. Cool!

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

@mauricioabreu great!

So, anyone working in this issue? If not, I'm assigning myself.

from speakerfight.

phrfpeixoto avatar phrfpeixoto commented on July 29, 2024

@wagnerluis1982 Are you working on this?

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

@phrfpeixoto yes, man!

I'm still planning things, but I'll have some code soon!

from speakerfight.

phrfpeixoto avatar phrfpeixoto commented on July 29, 2024

I think that make this a setting in the user model is a bit like an overkill. You simply use session and cookie approaches builtin in django. You can also use browser's local storage.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

Hmmm, we have to see what the others think!

In general I think you are right, but this hurts the user experience since the user needs to change the idiom every time he uses another computer or browser. Users that don't store cookies will not like it too.

Maybe there is a way to make this happens without performance problems.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

One suggestion.

  1. We try to use the language information from the Session/Cookies
  2. If not found we get the information from the database

To reduce the impact to performance, when the user changes the idiom, all his sessions, but the current one, will be closed. This makes that we don't have inconsistency of idioms among sessions.

Of course the user can set the idiom to be automatic, by the browser settings.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

Hi, in the #188 I added the LocaleMiddleware to get info from Accept-Language request header.

Although this middleware try to find the language info in the session, it doesn't write anything to the session so the next time this is done.

So I need to make a subclass of LocaleMiddleware to make that happens, where is the best place to put this class?

EDIT [04/11/2016]: Actually I need to adapt the LocaleMiddleware, so it searches in the user database if no language was found at the session or cookie.

from speakerfight.

wagnerluis1982 avatar wagnerluis1982 commented on July 29, 2024

Hi, to allow the user change his idiom I made the following design. Please, say what you think.

  1. The current idiom is showed next to user dropdown.

image

  1. We can change the language by clicking in the current idiom dropdown.

image

  1. And the idiom is changed 😄

image

from speakerfight.

abispo avatar abispo commented on July 29, 2024

I agree with this approach.

from speakerfight.

luanfonceca avatar luanfonceca commented on July 29, 2024

@wagnerluis1982 how is going that? Can you push some code to a PR?

from speakerfight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.