【发布时间】:2016-05-08 05:28:11
【问题描述】:
我是使用 ruby 和中间人的新手,我已经创建了我的项目并且一切正常,但是当我转到 /es 路径时,我没有得到任何翻译。我搜索了没有任何结果的信息,并试图在测试配置的文件夹之间移动代码,但什么也没有。
我的文件夹结构是:
|locales
|---en.yml
|---es.yml
|source
|es
|---index.html.haml
|layouts
|---layout.html.haml
|partials
|_header.html.haml
|_navigation.html.haml
|---index.html.haml
我的 YAML 文件
en.yml
en:
home: 'Home'
es.yml
es:
home: 'Inicio'
我的 HAML
%nav
= link_to t(:home), '/', class: "#{'active' if current_page.url == '/'}"
= link_to 'Portfolio', '/portfolio', class: "#{'active' if current_page.url == '/portfolio/'}"
= link_to t(:skills), '/skills', class: "#{'active' if current_page.url == '/skills/'}"
= link_to t(:about), '/about', class: "#{'active' if current_page.url == '/about/'}"
= link_to t(:contact), '/contact', class: "#{'active' if current_page.url == '/contact/'}"
我的配置
config.rb
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", locals: {
# which_fake_page: "Rendering a fake page with a local variable" }
# General configuration
set :partials_dir, 'partials'
activate :i18n, :templates_dir => 'partials'
activate :directory_indexes
# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end
###
# Helpers
###
# Methods defined in the helpers block are available in templates
# helpers do
# def some_helper
# "Helping"
# end
# end
# Build-specific configuration
configure :build do
# Minify CSS on build
activate :minify_css
# Minify Javascript on build
activate :minify_javascript
end
【问题讨论】:
-
您介意分享您的代码吗?
标签: ruby-on-rails rails-i18n middleman