LoginSignup
1
0

More than 3 years have passed since last update.

EC-CUBE4の多言語化対応(サブディレクトリで分けたり、ユーザー側画面と管理画面で分けたり)

Last updated at Posted at 2020-06-05

公式の多言語化対応の問題点

  • 各言語のmessages.[lang].yamlを用意しても一言語しか使えない。
  • ユーザー側画面と管理画面で表示言語を分けることが出来ない。

解決策

Symfony3のルーティング機能を使う。

下記のコード変更例では、.envファイルのECCUBE_LOCALEの値に関係なく、
ユーザー側画面は、URLのサブディレクトリによって日本語と英語の表示が分かれ、
管理画面は、日本語で固定表示される。

app/config/eccube/routes.yaml
# ユーザー側画面のルーティング
controllers:
    resource: ../../src/Eccube/Controller/
    type: annotation
    prefix: /{_locale}
    requirements:
        _locale: en|ja
# 管理画面のルーティング
admin_controllers:
    resource: ../../src/Eccube/Controller/Admin/
    type: annotation
    defaults:
        _locale: ja

課題

  • あくまでもソースファイルでの多言語化対応であるため、依然として、DBの中に入っている内容の多言語化は出来ない。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0