Coder Social home page Coder Social logo

Comments (12)

josevalim avatar josevalim commented on May 21, 2024

Yes, Gettext.locale always need to return something. It may just default to "en".

from gettext.

josevalim avatar josevalim commented on May 21, 2024

I am also wondering if the locale configuration should really be in Gettext.locale or if it should be per backend.

from gettext.

lexmag avatar lexmag commented on May 21, 2024

locale configuration should really be in Gettext.locale or if it should be per backend

It feels more intuitive to have it per backend, and more flexible.

from gettext.

whatyouhide avatar whatyouhide commented on May 21, 2024

I'm 👍 on making the locale per-backend. We can store it under MyApp.Gettext in the process dict and increment the arity of locale/0-1 to locale(backend) and locale(backend, locale). I'm not sure how we could configure it. We could use the Mix config for each backend:

config :my_app, MyApp.Gettext, default_locale: "pt_BR"

and also default to "en" if there's no config (which is the subject of the issue).

What do you think?

from gettext.

josevalim avatar josevalim commented on May 21, 2024

👍 for everything. Will we also have MyApp.Gettext.locale/0/1?

from gettext.

lexmag avatar lexmag commented on May 21, 2024

That sounds wonderful.

from gettext.

whatyouhide avatar whatyouhide commented on May 21, 2024

@josevalim I wouldn't provide both Gettext.locale/1-2 and MyApp.Gettext.locale/0-1 because they would do the exact same thing (but we would still have to test/document all of them). Also, we'd need to introduce MyApp.Gettext.with_locale/2 as well. Wdyt?

from gettext.

lexmag avatar lexmag commented on May 21, 2024

I do see the need for MyApp.Gettext.with_locale/2, not sure if we need MyApp.Gettext.locale/0-1 though.

from gettext.

josevalim avatar josevalim commented on May 21, 2024

Ok, we don't need to add any of them. Gettext.get_locale(backend) & Gettext.put_locale(backend, ...) would be my votes. I think it would be nice to change the name so it is clearer now with multiple args and so we effectively break the users code, otherwise it can accidentally pass.

from gettext.

whatyouhide avatar whatyouhide commented on May 21, 2024

Awesome, I'll come up with a PR soon.

from gettext.

lexmag avatar lexmag commented on May 21, 2024

Ah, get_ and put_ verbs – that's nice. 😄

from gettext.

whatyouhide avatar whatyouhide commented on May 21, 2024

I was 👍 for get_ and put_ from the beginning so I'm happy about this change :)

from gettext.

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.