前提・実現したいこと
Ruby on RailsでTwitterのbotを作っています。
新たな記事の登録機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
エラーメッセージ
ActionView::Template::Error (can not load translations from C:/Users/Owner/shikai_shosetu_bot/config/locales/ja.yml: #<Psych::SyntaxError: (C:/Users/Owner/shikai_shosetu_bot/config/locales/ja.yml): invalid leading UTF-8 octet at line 1 column 1>):
12: <% end %>
13:
14: <div class="field">
15: <%= form.label :content %><br>
16: <%= form.text_area :content, cols: 40, rows: 7 ,maxlength: 140 %><br>
17: </div>
18:
app/views/articles/_form.html.erb:15:in block in _app_views_articles__form_html_erb__947347935_109963960' app/views/articles/_form.html.erb:1:in
_app_views_articles__form_html_erb__947347935_109963960'
app/views/articles/new.html.erb:2:in `_app_views_articles_new_html_erb__447253411_109929160'
ActionView::Template::Error: can not load translations from C:/Users/Owner/shikai_shosetu_bot/config/locales/ja.yml: #<Psych::SyntaxError: (C:/Users/Owner/shikai_shosetu_bot/config/locales/ja.yml): invalid leading UTF-8 octet at line 1 column 1>
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/i18n-1.6.0/lib/i18n/backend/base.rb:244:in `rescue in load_yml'
該当のソースコード
yml
1--- 2ja: 3 activerecord: 4 errors: 5 messages: 6 record_invalid: '検証不能: %{errors}' 7 restrict_dependent_destroy: 8 has_one: "%{record}が依存しているため削除不能" 9 has_many: "%{record}が依存しているため削除不能" 10 date: 11 abbr_day_names: 12 - 日 13 - 月 14 - 火 15 - 水 16 - 木 17 - 金 18 - 土 19 abbr_month_names: 20 - 21 - 1月 22 - 2月 23 - 3月 24 - 4月 25 - 5月 26 - 6月 27 - 7月 28 - 8月 29 - 9月 30 - 10月 31 - 11月 32 - 12月 33 day_names: 34 - 日曜日 35 - 月曜日 36 - 火曜日 37 - 水曜日 38 - 木曜日 39 - 金曜日 40 - 土曜日 41 formats: 42 default: "%Y/%m/%d" 43 long: "%Y年%m月%d日(%a)" 44 short: "%m/%d" 45 month_names: 46 - 47 - 1月 48 - 2月 49 - 3月 50 - 4月 51 - 5月 52 - 6月 53 - 7月 54 - 8月 55 - 9月 56 - 10月 57 - 11月 58 - 12月 59 order: 60 - :year 61 - :month 62 - :day 63 datetime: 64 distance_in_words: 65 about_x_hours: 66 one: 約1時間 67 other: 約%{count}時間 68 about_x_months: 69 one: 約1ケ月 70 other: 約%{count}ケ月 71 about_x_years: 72 one: 約1年 73 other: 約1%{count}年 74 almost_x_years: 75 one: 1年 76 other: %{count}年 77 half_a_minute: 30秒間 78 less_than_x_seconds: 79 one: 1秒以内 80 other: "%{count}秒以内" 81 less_than_x_minutes: 82 one: 1分以内 83 other: "%{count}分以内" 84 over_x_years: 85 one: 1年以上 86 other: "%{count}年以上" 87 x_seconds: 88 one: 1秒 89 other: "%{count}秒" 90 x_minutes: 91 one: 1分 92 other: "%{count}分" 93 x_days: 94 one: 1日・ 95 other: "%{count}日" 96 x_months: 97 one: 1ケ月 98 other: "%{count}ケ月" 99 x_years: 100 one: 1年 101 other: "%{count}年" 102 prompts: 103 second: 秒 104 minute: 分 105 hour: 時間 106 day: 日 107 month: 月 108 year: 年 109 errors: 110 format: "%{attribute}%{message}" 111 messages: 112 accepted: を承諾しなければなりません 113 blank: には何か入力してください 114 confirmation: が%{attribute}と一致しません 115 empty: を空白にはできません 116 equal_to: は%{count}と値が一致していなければなりません 117 even: は偶数でなければなりません 118 exclusion: は予約語です 119 greater_than: は%{count}より大きくなければなりません 120 greater_than_or_equal_to: は%{count}以上でなければなりません 121 inclusion: はリストに含まれていません 122 invalid: の形式が正しくありません 123 less_than: は%{count}より小さくなければなりません 124 less_than_or_equal_to: は%{count}以下でなければなりません 125 model_invalid: '認証できませんでした: %{errors}' 126 not_a_number: は数字ではありません 127 not_an_integer: は整数でなければなりません 128 odd: は奇数でなければなりません 129 other_than: は%{count}以外でなければなりません 130 present: は空白でなければなりません 131 required: がなければなりません 132 taken: は既に使用されています 133 too_long: 長すぎるので、%{count}字以内にしてください 134 too_short: 短すぎるので、%{count}字以上にしてください 135 wrong_length: %{count}字にしてください template: 136 body: "以下の場所に問題があります:" 137 header: 138 one: "エラーのためこの%{model}は保存されませんでした" 139 other: "%{count}個あるエラーのため%{model}は保存されませんでした" 140 helpers: 141 select: 142 prompt: 選択してください 143 submit: 144 create: "%{model}を作成してください" 145 submit: %{model}を保存してください 146 update: "&{model}をアップデートしてください" 147 post: "%{model}を作成" 148 number: 149 currency: 150 format: 151 delimiter: "," 152 format: "%n%u" 153 precision: 0 154 separator: "." 155 significant: false 156 strip_insignificant_zeros: false 157 unit: "¥" 158 format: 159 delimiter: "," 160 precision: 3 161 separator: "." 162 significant: false 163 strip_insignificant_zeros: false 164 human: 165 decimal_units: 166 format: "%n %u" 167 units: 168 billion: 十億 169 million: 百万 170 quadrillion: 千兆 171 thousand: 千 172 trillion: 兆 173 unit: '' 174 format: 175 delimiter: '' 176 precision: 3 177 significant: true 178 strip_insignificant_zeros: true 179 storage_units: 180 format: "%n%u" 181 units: 182 byte: バイト 183 eb: EB 184 gb: GB 185 kb: KB 186 mb: MB 187 pb: PB 188 tb: TB 189 percentage: 190 format: 191 delimiter: '' 192 format: "%n%" 193 precision: 194 format: 195 delimiter: '' 196 support: 197 array: 198 last_word_connector: "㠄" 199 two_words_connector: "や" 200 words_connector: "、" 201 time: 202 am: 午前 203 formats: 204 default: "%Y年%m月%d日(%a) %H時%M分%S秒%z" 205 long: "%Y/%m/%d %H:%M" 206 short: "%m/%d %H:%M" 207 pm: 午後 208 view: 209 dounano: 実際どうなの使えるの
試したこと
RubyがUnicodeさえ読み込んでくれなかったので、htmlで扱うものだし、ネットでダウンロードしたja.ymlファイルをunicodeに書き換えた。
補足情報(FW/ツールのバージョンなど)
ruby 2.6.2p47 (2019-03-13 revision 67232) [x64-mingw32]
i18n-1.6.0
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。