Rails 4 custom translations per User -


we have cms application allows create shops backend multiple users.. when want implement translations face problem. translations stored locale need user.id , locale. because each user can have own translations per language.

i tried implement i18n backend described in railscast stucking http://railscasts.com/episodes/256-i18n-backends?view=asciicast customization per user.

is there way add additional column translations , ask local , user_id?

many thanks

there not single best solution given problem. depends on application. given information have i'd suggest like:

app/controllers/application_controller.rb

class applicationcontroller < actioncontroller::base   protect_from_forgery with: :exception    before_filter :set_locale    private   def set_locale     i18n.locale = current_user.language || i18n.default_locale   end end 

this set 18n.locale language settings of current_user. need language attribute in users model work.

please have @ http://xyzpub.com/en/ruby-on-rails/4.0/i18n.html more examples.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -