質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

473閲覧

Rails がform.labelを読み込んでくれない

resignater

総合スコア12

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/06/23 09:17

前提・実現したいこと

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: '&#x691c;&#x8a3c;&#x4e0d;&#x80fd;: %{errors}' 7 restrict_dependent_destroy: 8 has_one: "%{record}&#x304c;&#x4f9d;&#x5b58;&#x3057;&#x3066;&#x3044;&#x308b;&#x305f;&#x3081;&#x524a;&#x9664;&#x4e0d;&#x80fd;" 9 has_many: "%{record}&#x304c;&#x4f9d;&#x5b58;&#x3057;&#x3066;&#x3044;&#x308b;&#x305f;&#x3081;&#x524a;&#x9664;&#x4e0d;&#x80fd;" 10 date: 11 abbr_day_names: 12 - &#x65e5; 13 - &#x6708; 14 - &#x706b; 15 - &#x6c34; 16 - &#x6728; 17 - &#x91d1; 18 - &#x571f; 19 abbr_month_names: 20 - 21 - 1&#x6708; 22 - 2&#x6708; 23 - 3&#x6708; 24 - 4&#x6708; 25 - 5&#x6708; 26 - 6&#x6708; 27 - 7&#x6708; 28 - 8&#x6708; 29 - 9&#x6708; 30 - 10&#x6708; 31 - 11&#x6708; 32 - 12&#x6708; 33 day_names: 34 - &#x65e5;&#x66dc;&#x65e5; 35 - &#x6708;&#x66dc;&#x65e5; 36 - &#x706b;&#x66dc;&#x65e5; 37 - &#x6c34;&#x66dc;&#x65e5; 38 - &#x6728;&#x66dc;&#x65e5; 39 - &#x91d1;&#x66dc;&#x65e5; 40 - &#x571f;&#x66dc;&#x65e5; 41 formats: 42 default: "%Y/%m/%d" 43 long: "%Y&#x5e74;%m&#x6708;%d&#x65e5(%a)" 44 short: "%m/%d" 45 month_names: 46 - 47 - 1&#x6708; 48 - 2&#x6708; 49 - 3&#x6708; 50 - 4&#x6708; 51 - 5&#x6708; 52 - 6&#x6708; 53 - 7&#x6708; 54 - 8&#x6708; 55 - 9&#x6708; 56 - 10&#x6708; 57 - 11&#x6708; 58 - 12&#x6708; 59 order: 60 - :year 61 - :month 62 - :day 63 datetime: 64 distance_in_words: 65 about_x_hours: 66 one: &#x7d04;1&#x6642;&#x9593; 67 other: &#x7d04;%{count}&#x6642;&#x9593; 68 about_x_months: 69 one: &#x7d04;1&#x30b1;&#x6708; 70 other: &#x7d04;%{count}&#x30b1;&#x6708; 71 about_x_years: 72 one: &#x7d04;1&#x5e74; 73 other: &#x7d04;1%{count}&#x5e74; 74 almost_x_years: 75 one: 1&#x5e74; 76 other: %{count}&#x5e74; 77 half_a_minute: 30&#x79d2;&#x9593; 78 less_than_x_seconds: 79 one: 1&#x79d2;&#x4ee5;&#x5185; 80 other: "%{count}&#x79d2;&#x4ee5;&#x5185;" 81 less_than_x_minutes: 82 one: 1&#x5206;&#x4ee5;&#x5185; 83 other: "%{count}&#x5206;&#x4ee5;&#x5185;" 84 over_x_years: 85 one: 1&#x5e74;&#x4ee5;&#x4e0a; 86 other: "%{count}&#x5e74;&#x4ee5;&#x4e0a;" 87 x_seconds: 88 one: 1&#x79d2; 89 other: "%{count}&#x79d2;" 90 x_minutes: 91 one: 1&#x5206; 92 other: "%{count}&#x5206;" 93 x_days: 94 one: 1&#x65e5・ 95 other: "%{count}&#x65e5" 96 x_months: 97 one: 1&#x30b1;&#x6708; 98 other: "%{count}&#x30b1;&#x6708;" 99 x_years: 100 one: 1&#x5e74; 101 other: "%{count}&#x5e74;" 102 prompts: 103 second: &#x79d2; 104 minute: &#x5206; 105 hour: &#x6642;&#x9593; 106 day: &#x65e5; 107 month: &#x6708; 108 year: &#x5e74; 109 errors: 110 format: "%{attribute}%{message}" 111 messages: 112 accepted: &#x3092;&#x627f;&#x8afe;&#x3057;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 113 blank: &#x306b;&#x306f;&#x4f55;&#x304b;&#x5165;&#x529b;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; 114 confirmation: &#x304c;%{attribute}&#x3068;&#x4e00;&#x81f4;&#x3057;&#x307e;&#x305b;&#x3093; 115 empty: &#x3092;&#x7a7a;&#x767d;&#x306b;&#x306f;&#x3067;&#x304d;&#x307e;&#x305b;&#x3093; 116 equal_to: &#x306f;%{count}&#x3068;&#x5024;&#x304c;&#x4e00;&#x81f4;&#x3057;&#x3066;&#x3044;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 117 even: &#x306f;&#x5076;&#x6570;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 118 exclusion: &#x306f;&#x4e88;&#x7d04;&#x8a9e;&#x3067;&#x3059; 119 greater_than: &#x306f;%{count}&#x3088;&#x308a;&#x5927;&#x304d;&#x304f;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 120 greater_than_or_equal_to: &#x306f;%{count}&#x4ee5;&#x4e0a;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 121 inclusion: &#x306f;&#x30ea;&#x30b9;&#x30c8;&#x306b;&#x542b;&#x307e;&#x308c;&#x3066;&#x3044;&#x307e;&#x305b;&#x3093; 122 invalid: &#x306e;&#x5f62;&#x5f0f;&#x304c;&#x6b63;&#x3057;&#x304f;&#x3042;&#x308a;&#x307e;&#x305b;&#x3093; 123 less_than: &#x306f;%{count}&#x3088;&#x308a;&#x5c0f;&#x3055;&#x304f;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 124 less_than_or_equal_to: &#x306f%{count}&#x4ee5;&#x4e0b;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 125 model_invalid: '&#x8a8d;&#x8a3c;&#x3067;&#x304d;&#x307e;&#x305b;&#x3093;&#x3067;&#x3057;&#x305f;: %{errors}' 126 not_a_number: &#x306f;&#x6570;&#x5b57;&#x3067;&#x306f;&#x3042;&#x308a;&#x307e;&#x305b;&#x3093; 127 not_an_integer: &#x306f;&#x6574;&#x6570;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 128 odd: &#x306f;&#x5947;&#x6570;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 129 other_than: &#x306f;%{count}&#x4ee5;&#x5916;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 130 present: &#x306f;&#x7a7a;&#x767d;&#x3067;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 131 required: &#x304c;&#x306a;&#x3051;&#x308c;&#x3070;&#x306a;&#x308a;&#x307e;&#x305b;&#x3093; 132 taken: &#x306f;&#x65e2;&#x306b;&#x4f7f;&#x7528;&#x3055;&#x308c;&#x3066;&#x3044;&#x307e;&#x3059; 133 too_long: &#x9577;&#x3059;&#x304e;&#x308b;&#x306e;&#x3067;&#x3001;%{count}&#x5b57;&#x4ee5;&#x5185;&#x306b;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; 134 too_short: &#x77ed;&#x3059;&#x304e;&#x308b;&#x306e;&#x3067;&#x3001;%{count}&#x5b57;&#x4ee5;&#x4e0a;&#x306b;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; 135 wrong_length: %{count}&#x5b57;&#x306b;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; template: 136 body: "&#x4ee5;&#x4e0b;&#x306e;&#x5834;&#x6240;&#x306b;&#x554f;&#x984c;&#x304c;&#x3042;&#x308a;&#x307e;&#x3059;:" 137 header: 138 one: "&#x30a8;&#x30e9;&#x30fc;&#x306e;&#x305f;&#x3081;&#x3053;&#x306e;%{model}&#x306f;&#x4fdd;&#x5b58;&#x3055;&#x308c;&#x307e;&#x305b;&#x3093;&#x3067;&#x3057;&#x305f;" 139 other: "%{count}&#x500b;&#x3042;&#x308b;&#x30a8;&#x30e9;&#x30fc;&#x306e;&#x305f;&#x3081;%{model}&#x306f;&#x4fdd;&#x5b58;&#x3055;&#x308c;&#x307e;&#x305b;&#x3093;&#x3067;&#x3057;&#x305f;" 140 helpers: 141 select: 142 prompt: &#x9078;&#x629e;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; 143 submit: 144 create: "%{model}&#x3092;&#x4f5c;&#x6210;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044;" 145 submit: %{model}&#x3092;&#x4fdd;&#x5b58;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044; 146 update: "&{model}&#x3092;&#x30a2;&#x30c3;&#x30d7;&#x30c7;&#x30fc;&#x30c8;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044;" 147 post: "%{model}&#12434;&#20316;&#25104;" 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: "&#xffe5;" 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: &#x5341;&#x5104; 169 million: &#x767e;&#x4e07; 170 quadrillion: &#x5343;&#x5146; 171 thousand: &#x5343; 172 trillion: &#x5146; 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: &#x30d0;&#x30a4;&#x30c8; 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: "&#x3804;" 199 two_words_connector: "&#x3084;" 200 words_connector: "&#x3001;" 201 time: 202 am: &#x5348;&#x524d; 203 formats: 204 default: "%Y&#x5e74;%m&#x6708;%d&#x65e5;(%a) %H&#x6642;%M&#x5206;%S&#x79d2;%z" 205 long: "%Y/%m/%d %H:%M" 206 short: "%m/%d %H:%M" 207 pm: &#x5348;&#x5f8c; 208 view: 209 dounano: &#23455;&#38555;&#12393;&#12358;&#12394;&#12398;&#20351;&#12360;&#12427;&#12398;

試したこと

RubyがUnicodeさえ読み込んでくれなかったので、htmlで扱うものだし、ネットでダウンロードしたja.ymlファイルをunicodeに書き換えた。

補足情報(FW/ツールのバージョンなど)

ruby 2.6.2p47 (2019-03-13 revision 67232) [x64-mingw32]
i18n-1.6.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

結局i18nをあきらめたら何とかなりました

投稿2019/06/24 02:25

resignater

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

loadに失敗しているように見えるので一度spring止めてみると良さそうです〜。

sprint stop

投稿2019/06/23 10:46

t_kusakabe74

総合スコア549

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問