Skip to content

Instantly share code, notes, and snippets.

@luctus
Created April 21, 2016 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luctus/24bb58215f6c62b6aabeb677c8a4e32f to your computer and use it in GitHub Desktop.
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
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
@luctus
Copy link
Author

luctus commented Apr 22, 2016

Then, you can visit /en for the english version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment