初心者で簡単なCRUD処理を実装したアプリを作成して、練習しています。
今回はscaffoldで作成したものにbootstrapを適用するという流れを実践しています。
その中で、英語で表記されたviewを、日本語で表示してあげる、という作業をしています。国際化する作業です。
動画教材で学習を進めていたのですが、タイトルのエラーメッセージが出てきてしまいます。
形式の変換ができないよ、シナックスエラーとあるので、indexのこの文をja.ymlにて編集するのかな?と仮定していますが、
解決に至らないので一緒に見てもらえないでしょうか。お願い致します。
application.rbを編集、
en.bootstrap.ymlをja.bootstrap.yml,
en.ymlをja.ymlとし、複製、編集しました。
###application.rb
rb
1require_relative 'boot' 2 3require 'rails/all' 4 5# Require the gems listed in Gemfile, including any gems 6# you've limited to :test, :development, or :production. 7Bundler.require(*Rails.groups) 8 9module Dokusho 10 class Application < Rails::Application 11 # Initialize configuration defaults for originally generated Rails version. 12 config.load_defaults 5.2 13 config.i18n.load_path += Dir[Rails.root.join('config','locales','*.{rb,yml}').to_s] 14 config.i18n.default_locale = :ja 15 # Settings in config/environments/* take precedence over those specified here. 16 # Application configuration can go into files in config/initializers 17 # -- all .rb files in that directory are automatically loaded after loading 18 # the framework and any gems in your application. 19 end 20end
###ja.bootstrap.yml
rb
1# Sample localization file for English. Add more files in this directory for other locales. 2# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 4ja: 5 breadcrumbs: 6 application: 7 root: "インデックス" 8 pages: 9 pages: "Pages" 10 helpers: 11 actions: "Actions" 12 links: 13 back: "戻る" 14 cancel: "キャンセル" 15 confirm: "よろしいですか?" 16 destroy: "削除" 17 new: "新規" 18 edit: "編集" 19 titles: 20 edit: "編集 %{model}" 21 save: "保存 %{model}" 22 new: "新規 %{model}" 23 delete: "削除 %{model}"
###ja.yml
rb
1# Files in the config/locales directory are used for internationalization 2# and are automatically loaded by Rails. If you want to use locales other 3# than English, add the necessary files in this directory. 4# 5# To use the locales, use `I18n.t`: 6# 7# I18n.t 'hello' 8# 9# In views, this is aliased to just `t`: 10# 11# <%= t('hello') %> 12# 13# To use a different locale, set it with `I18n.locale`: 14# 15# I18n.locale = :es 16# 17# This would use the information in config/locales/es.yml. 18# 19# The following keys must be escaped otherwise they will not be retrieved by 20# the default I18n backend: 21# 22# true, false, on, off, yes, no 23# 24# Instead, surround them with single quotes. 25# 26# en: 27# 'true': 'foo' 28# 29# To learn more, please read the Rails Internationalization guide 30# available at http://guides.rubyonrails.org/i18n.html. 31 32ja: 33 time: 34 formats: 35 default: "%Y/%m/%d" %H:%M:%S" 36 am: 午前 37 pm: 午後
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。