Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global fallback_locale is ignored #15

Open
mattpepin opened this issue Mar 23, 2015 · 3 comments
Open

Global fallback_locale is ignored #15

mattpepin opened this issue Mar 23, 2015 · 3 comments

Comments

@mattpepin
Copy link

I use a global fallback_locale when I call make_translatable. Yet, it is sometimes overridden because of the following in class Translatable:

translatable = {
'fallback_locale': 'en'
}

I think it's a bug because otherwise, I have to specify the fallback_locale in every translated class.

@angelosarto
Copy link

I think I am having the same issue. How are you setting the fallback on the individual translated classes?

@mattpepin
Copy link
Author

In translatable.py, comment the following line:

class Translatable(object):
    __translatable__ = {
        # 'fallback_locale': 'en'
}

You will then be able to set a global locale like so:

def get_locale():
    return 'fr_CA'  # Probably not a constant but you get the idea
sqlalchemy_utils.i18n.get_locale = get_locale

@angelosarto
Copy link

I see you just commented out the fallback locale all together.
I extended Translatable and overrode translatable and implemented my classes on top -- working around the same issue though:

class Default_Translatable(Translatable):
    __translatable__ = {'fallback_locale': 'en-US'}

and then in my classes:

class Group(base.Base, base.Default_Translatable):
    __tablename__ = 'Groups'
    ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants