Created
April 21, 2016 20:42
-
-
Save luctus/24bb58215f6c62b6aabeb677c8a4e32f to your computer and use it in GitHub Desktop.
Example of a mini application using the Cuba framework (ruby) + HAML render engine + i18N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "cuba" | |
require "cuba/render" | |
require "tilt/haml" | |
require "sass" | |
require "i18n" | |
require "i18n/backend/fallbacks" | |
Cuba.plugin Cuba::Render | |
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) | |
I18n.load_path = Dir["./locales/*.yml"] | |
I18n.backend.load_translations | |
I18n.default_locale = :en | |
Cuba.settings[:render][:template_engine] = "haml" | |
Cuba.define do | |
on "(en|es|pt|co|pe|br|cn)" do |locale| | |
I18n.locale = locale | |
on root do | |
res.write partial("super_partial") | |
end | |
end | |
on 'stylesheets', extension('css') do |file| | |
on get do | |
res['Content-Type'] = 'text/css' | |
res.write render("assets/stylesheets/#{File.basename(file)}.scss") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then, you can visit
/en
for the english version