Skip to navigation
How to add a simple language switcher in merb
07.12.13
1. create language yml files like: lang/en.yml 2.edit them like: :text_1: hello :text_2: good bye 3. put in your controller: before :language 4. put into your application.rb the following function: def language() if session[:lang] @lang = YAML.load_file( "lang/#{session[:lang]}.yml" ) else @lang = YAML.load_file( 'lang/en.yml' ) session[:lang] = 'en' end end 5. create switch function where it change the session[:lang] value
Reply
Anonymous
How to add a simple language switcher in merb
1. create language yml files like: lang/en.yml 2.edit them like: :text_1: hello :text_2: good bye 3. put in your controller: before :language 4. put into your application.rb the following function: def language() if session[:lang] @lang = YAML.load_file( "lang/#{session[:lang]}.yml" ) else @lang = YAML.load_file( 'lang/en.yml' ) session[:lang] = 'en' end end 5. create switch function where it change the session[:lang] value
07.12.13
Reply
Anonymous
Information Epoch 1732527278
Build a prototype as soon as possible.
Home
Notebook
Contact us