Help us understand the problem. What is going on with this article?

【CraftCMS】出力値を翻訳する

More than 1 year has passed since last update.

下準備

翻訳する値を格納するディレクトリを作る

mkdir craft/translations

とりあえず英語でやるとして

# cd translations
mkdir en
touch site.php

site.phpで英語対応する文字を定義する

site.php
return [
           "必須"  => "req",
           "お名前" => "name",
       ];

コンパネ→設定→サイトで英語版サイトのURLを定義する

スクリーンショット 2019-04-22 11.03.18.png

実装

あとはtwigでtranslateフィルタを掛けるだけ

{{お名前|t}}
{{必須|t}}

確認

日本語版 (mentaicoo.jp)

名称未設定.png


英語版 (mentaicoo.jp/en)

スクリーンショット 2019-04-22 11.10.29.png

結論

ということでCMSで管理しない固定値も楽々多言語対応が可能
という話でした。

おわり。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした