简体   繁体   English

Spree Commerce 中前端和后端的不同语言环境

[英]Different locales for front-end and back-end in Spree Commerce

I need to set 2 separate static locales so front-end is always in English and back-end in Russian.我需要设置 2 个单独的静态语言环境,因此前端始终使用英语,后端始终使用俄语。
Adding this to /config/initializers/spree.rb or /app/controllers/application_controller.rb has no effect:将此添加到/config/initializers/spree.rb/app/controllers/application_controller.rb没有效果:

Spree::Frontend::Config[:locale] = :en
Spree::Backend::Config[:locale] = :ru

There was a PR where Ryan Bigg addressed this issue when splitting core in front-end and back-end https://github.com/spree/spree/commit/78b032dcfc02d362af780d6154ff300fbc0e95b0有一个 PR,Ryan Bigg 在前端和后端拆分核心时解决了这个问题https://github.com/spree/spree/commit/78b032dcfc02d362af780d6154ff300fbc0e95b0

I just couldn't find where to put the code or maybe my code is incorrect.我只是找不到放置代码的位置,或者我的代码不正确。

You could try the following:您可以尝试以下操作:

# app/controllers/spree/admin/base_controller_decorator.rb
Spree::Admin::BaseController.class_eval do
  before_filter do
    I18n.locale = :ru
  end
end

What worked for me to get the Backend in a custom locale (different than the Frontend locale) was adding this to app/config/initializers/spree.rb :在自定义语言环境(不同于前端语言环境)中获取后端对我app/config/initializers/spree.rb是将其添加到app/config/initializers/spree.rb

Spree::Backend::Config[:locale] = :ru

This is on Spree 4.1 (Rails 6.0.3.2)这是在 Spree 4.1 (Rails 6.0.3.2) 上

在 Spree 4.2 多货币是 OOTB,您可以为店面和管理面板设置不同的多个区域设置 - https://guides.spreecommerce.org/release_notes/4_2_0.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM