【发布时间】:2013-02-19 16:19:35
【问题描述】:
我有一个德语名称为“kontakt”的页面,但访问权限是 /contact。 我开始解决这个错误,思考翻译并在以下方面进行了更改:
(控制器)查询-controller.rb: 改变
def find_page
@page = ::Refinery::Page.find_by_link_url("/kontakt")
end
i18n.rb:
config.enabled = true
config.default_locale = :de
config.current_locale = :de
config.default_frontend_locale = :de
config.frontend_locales = [:en, :de]
config.locales = { :en => 'English', :de => 'Deutsch' }
我更改了(模型)setting.rb:
def confirmation_subject(locale="de")...
而不是“en”。
我将refinerycms 中的重定向更改为/kontakt。
我在浏览器中收到错误“页面未正确重定向”。
控制台:
在 2013-02-19 17:07:27 +0100 开始为 127.0.0.1 获取“/kontakt” 由 Refinery::PagesController#show 处理为 HTML 参数: {"path"=>"kontakt", "locale"=>:de} Refinery::Role Load (0.2ms) SELECT “炼油厂角色”。*来自“炼油厂角色”在哪里 "refinery_roles"."title" = 'Refinery' LIMIT 1 Refinery::User Load (0.2ms) SELECT "refinery_users".* FROM "refinery_users" INNER JOIN "refinery_roles_users" ON "refinery_users"."id" = “refinery_roles_users”。“user_id”在哪里 "refinery_roles_users"."role_id" = 1 Refinery::Page Load (0.4ms) SELECT "refinery_pages".* FROM "refinery_pages" INNER JOIN “炼油厂页面翻译”开启 "refinery_page_translations"."refinery_page_id" = "refinery_pages"."id" WHERE "refinery_page_translations"."locale" IN ('en', 'de') AND "refinery_page_translations"."slug" = 'kontakt' AND "refinery_pages"."parent_id" IS NULL LIMIT 1 重定向到 ../kontakt Refinery::User Load (0.1ms) SELECT "refinery_users".* FROM "refinery_users" WHERE "refinery_users"."id" = 3 LIMIT 1 Refinery::Role Load (0.1ms) SELECT "refinery_roles".* FROM "refinery_roles" 内部联接 "refinery_roles_users" ON "refinery_roles"."id" = "refinery_roles_users"."role_id" WHERE "refinery_roles_users"."user_id" = 3 完成 302 在 8 毫秒内找到 (ActiveRecord:1.1ms)缓存:[GET /kontakt] 未命中缓存:[GET /kontakt] 错过
development.log的日志:
在 2013-02-19 17:07:27 +0100 开始为 127.0.0.1 获取“/kontakt” 由 Refinery::PagesController#show 处理为 HTML 参数: {"path"=>"kontakt", "locale"=>:de} [1m[35mRefinery::Role Load (0.1ms)[0m SELECT "refinery_roles".* FROM "refinery_roles" WHERE "refinery_roles"."title" = '炼油厂' LIMIT 1
[1m[36mRefinery::用户负载(0.2ms)[0m [1mSELECT "refinery_users".* FROM "refinery_users" INNER JOIN "refinery_roles_users" ON "refinery_users"."id" = “refinery_roles_users”。“user_id”在哪里 "refinery_roles_users"."role_id" = 1[0m [1m[35mRefinery::Page 加载 (0.2ms)[0m SELECT "refinery_pages".* FROM "refinery_pages" INNER JOIN "refinery_page_translations" ON "refinery_page_translations"."refinery_page_id" = "refinery_pages"."id" WHERE "refinery_page_translations"."locale" IN ('en', 'de') AND "refinery_page_translations"."slug" = 'kontakt' AND "refinery_pages"."parent_id" IS NULL LIMIT 1 重定向到 //../kontakt [1m[36mRefinery::User Load (0.1ms)[0m [1mSELECT "refinery_users".* FROM "refinery_users" WHERE "refinery_users"."id" = 3 LIMIT 1[0m [1m[35mRefinery::Role Load (0.1ms)[0m SELECT "refinery_roles".* FROM "refinery_roles" INNER 加入 "refinery_roles_users" ON "refinery_roles"."id" = "refinery_roles_users"."role_id" WHERE "refinery_roles_users"."user_id" = 3 完成 302 发现时间为 6 毫秒 (ActiveRecord: 0.8ms)
我在文件中有翻译: en.yml 和 de.yml
我在http://refinerycms.com/edge-guides/translate-refinery看到了信息 但我找不到解决方案。
如果我尝试使用 /contact 输入,效果很好,即使进行了所有更改。
此外,在页面的公式中,验证是读取英文值。
【问题讨论】:
-
会不会是:
@page = ::Refinery::Page.find_by_link_url(t.contact)?
标签: ruby-on-rails ruby internationalization translation refinerycms