天道酬勤,学无止境

blacklight

`link_to` with parameters for an Engine route

(While this discusses Blacklight engine, I believe the question is actually purely about Rails.) Continuing my quest from scope around mount ineffective? (tl;dr: make the engine routes obey the same :locale scope as application routes), after digging through Rails source. Currently, I have this setup: # config/routes.rb Rails.application.routes.draw do Blacklight::Engine.routes.default_scope = { path: "(:locale)", locale: /en|ja/ } mount Blacklight::Engine => '/' scope "(:locale)", locale: /en|ja/ do # ... end end This makes the routes work properly. However, I had this view code to generate

2022-03-18 09:26:26    分类:问答    ruby-on-rails   url-routing   rails-engines   blacklight

切换区域设置后需要刷新页面以进行 Blacklight 标签翻译(Page needs to be refreshed after switching locale for Blacklight label to translate)

问题 我正在尝试创建基于 Blacklight 的 Rails 应用程序的阿拉伯语版本。 这是我面临的问题: 当我切换语言时,除了 Blacklight 标签之外,所有内容都可以完美翻译。 只有当我刷新页面时标签才会被翻译。 这是我要显示的标签:“ترتيب حسب عام”(翻译:按年份排序) 但这就是我目前得到的:“Year ترتيب حسب” 从阿拉伯语切换回英语时会发生同样的问题 - 标签显示为阿拉伯语,直到我刷新页面。 这是我的 Blacklight 配置的样子: class CatalogController < ApplicationController include Blacklight::Catalog configure_blacklight do |config| # ... config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => I18n.t('sortby.year') # ... end end 这是我在应用程序控制器中设置语言环境的方式: class ApplicationController < ActionController::Base before_filter :set_locale def set_locale I18n.locale = params[

2022-01-14 14:48:22    分类:技术分享    ruby-on-rails   rails-i18n   blacklight

Page needs to be refreshed after switching locale for Blacklight label to translate

I am trying to create an Arabic version of a Rails app which is based on Blacklight. Here's the problem I am facing: When I switch the language, everything translates perfectly EXCEPT the Blacklight labels. It's only when I refresh the page that the labels get translated. This is the label I want to display: "ترتيب حسب عام" (Translation: Sort by Year) But this is what I am getting currently: "Year ترتيب حسب" The same issue happens when switching back to English from Arabic - the label displays in Arabic until I refresh the page. This is what my Blacklight configuration looks like: class

2022-01-08 06:56:45    分类:问答    ruby-on-rails   rails-i18n   blacklight

“mount”周围的“scope”无效?(`scope` around `mount` ineffective?)

问题 (虽然这里讨论的是 Blacklight 引擎,但我相信这个问题实际上纯粹是关于 Rails 的。) 我正在尝试为我的 Blacklight 应用程序添加国际化。 为此,我 将config/routes.rb所有内容都config/routes.rb到scope "(:locale)", locale: /en|ja/和在app/controllers/application_controller.rb我添加before_action :set_locale并覆盖default_url_options 按照 Rails i18n 指南的建议。 大多数事情都有效,但有一件事我无法弄清楚。 我所有的应用程序路由都被正确映射,例如http://www.example.com/en/catalog/12345与(/:locale)/catalog/:id(.:format)正确匹配,并被路由到catalog#show与{:id=>/[^\/]+(?=\.json|\.html|$|\/)/, :locale=>/en|ja/} Devise 的所有 URL 都很好。 一切正常......除了mount -ed Blacklight 引擎。 显然,Blacklight 引擎不侦听scope 。 rake routes显示: Routes for Blacklight::Engine

2021-10-16 01:40:53    分类:技术分享    ruby-on-rails   internationalization   url-routing   blacklight

`scope` around `mount` ineffective?

(While this discusses Blacklight engine, I believe the question is actually purely about Rails.) I am trying to add internationalisation to my Blacklight app. To that end, I wrapped everything in config/routes.rb into scope "(:locale)", locale: /en|ja/, and in app/controllers/application_controller.rb I added before_action :set_locale and overrode default_url_options as suggested by Rails i18n guide. Most things work, but there's one thing I haven't been able to figure out. All of my application routes are correctly mapped, e.g. http://www.example.com/en/catalog/12345 correctly matches with (/

2021-09-04 23:21:37    分类:问答    ruby-on-rails   internationalization   url-routing   blacklight