Hi, this is Teppei Mimachi! !!
When you're proming, you'll find things you don't understand! ?? I think that I will do this for the first implementation and error resolution, but in such a case, I will look it up in a book or ask people, but after all the best thing is to look it up by google Isn't that a thing ...?
At least I have googled to solve more than 90% of the problems.
But ... but.
For example, even if you investigate this and that for the problem that appeared in Ruby on Rails, you can develop the application under exactly the same conditions as the development environment is different, the database is different, the version is different, and the application name is different. The possibility of being there is infinitely 0. There is always a difference somewhere.
If you just copy and paste due to such a subtle difference, you will not be able to implement it or solve the error, and eventually you will be disgusted and stop.
To prevent this from happening, I found one way to solve the problem by paying attention to it when confronting the problem, so I would like to introduce it.
As the title says, the answer is __ "To solve the problem, you can solve it by referring to the two articles !!!" __. This is the conclusion of this time, but it is difficult to understand by this alone, so please give a reference example!
First of all, the wall I'm facing when I google it is the place where I don't know how to do it.
As a result of investigating the question, I was in a state of incomprehensible, but this time I was looking for a solution to the problem that I do not know how to write ja.yml.
As for the state, I want to display all error messages displayed when the text field "__Introduction" is blank in the post form in Japanese. __
In other words, please enter __Content. You want to make Content in Japanese.
By the way, __Contet is the column name __ of the database (post table) you want to save.
If you google, many similar articles may get caught in the search. While referring to articles that are easy for me to understand and the situation is similar, I Japanese localization of Rails validation error message --Qiita I referred to this article.
As a result of reference ↑ I created __ja.yml__ like this and entered it.This is Japanese localization of Rails validation error message --Qiita I just copied and pasted the code for Japaneseization of __column names.
This result is actually the image of the post form I showed you earlier. ↓ Reposted.
Well ... In other words, just copying and pasting the __ code did not solve the problem of wanting to translate this column into Japanese.
Something is wrong with ja.yml ... what's wrong ...! ?? In such a question, while re-examining the Japanese localization of error messages, [Change the format of error messages displayed in ActiveRecord validates --Qiita] (https://qiita.com/okeicalm/items/9638250ddfb361d80a16) Discover this article! !!
And with ja.yml,
config/local/models/ja.yml
ja:
activerecord:
models:
user:user
attributes:
user:
name:name
↑ I found the above code!
config/local/models/ja.yml
ja:
activerecord:
models:
event:Event
attributes:
event:
name:event name
place:Venue
content:Event content
↑ This is the code I am currently using.
Now let's get back to the title. __ You can solve the problem by referring to the two articles !!! __ Return to.
Looking at the two codes, this is
config/local/models/ja.yml
ja:
activerecord:
models:
user:user
attributes:
user:
name:name
↑ In this code, __user: __,
config/local/models/ja.yml
ja:
activerecord:
models:
event:Event
attributes:
event:
name:event name
place:Venue
content:Event content
↑ In this code, I noticed that the __event: __ part is table name ...
[Before] ↓ [After] Change it like this ...
The result of restarting the server is
__ I was able to translate all the error messages into Japanese! !! __
Again, __ "To solve the problem, you can solve it by referring to the two articles !!!" __ is now complete.
...For your information.
Recommended Posts