Changeset fd6da93 in OpenWorkouts-current for ow/schemas/user.py


Ignore:
Timestamp:
Feb 26, 2019, 11:11:43 AM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
a4e4799
Parents:
d411dae
Message:

(#56) Add support for different locale/language:

  • Let users choose their lang/locale in the edit profile page
  • Set the currently selected locale as a cookie (following pyramid docs on how to set the locale using the default locale negotiator)
  • Save the locale setting for each user as an attribute on the User model
  • Set the proper locale as a cookie on login
  • Unset the locale cookie on logout

Default available locales for now are en (english) and es (spanish)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/schemas/user.py

    rd411dae rfd6da93  
    44
    55from ow.schemas.blob import FieldStorageBlob
     6from ow.utilities import get_available_locale_names
    67
    78_ = TranslationStringFactory('OpenWorkouts')
     
    7677                               whitelist=['jpg', 'jpeg', 'png', 'gif'])
    7778    timezone = validators.OneOf(common_timezones, if_missing='UTC')
     79    locale = validators.OneOf(
     80        [locale[0] for locale in get_available_locale_names()],
     81        if_missing='en'
     82    )
    7883
    7984
Note: See TracChangeset for help on using the changeset viewer.