# How to find translation for validation message?

**URL:** https://meta.discourse.org/t/how-to-find-translation-for-validation-message/42624
**Category:** Translations
**Created:** [Avril 15, 2016, 5:15 UTC](https://meta.discourse.org/t/how-to-find-translation-for-validation-message/42624 "2016-04-15T17:15:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![fantasticfears](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantasticfears/32/119608_2.png) [@fantasticfears](https://meta.discourse.org/u/fantasticfears)
#### Post date: [Avril 15, 2016, 5:15 UTC](https://meta.discourse.org/t/how-to-find-translation-for-validation-message/42624/1 "2016-04-15T17:15:04Z")

</div>

You might wonder where is the translation for messages like:

- Title has already been used
- Title is invalid…

Those error messages could show when you create or update something. But the translation is a bit harder to find out. They are generated by Rails.

You can find the general format by searching key `errors.format` which is `%{attribute} %{message}`. In the example above, `%{attribute}` is `title` and `%{message}` are generated by `errors.messages.has_already_been_used` and `errors.messages.is_invalid`.

Those attributes are translated by keys under `activerecord.attributes`. For example, when Rails validates topic, if there is error, Rails will look into `activerecord.attributes.topic.title`. If there isn’t a translation, it will fall back to code - `Title` in this case.

### Translation tips

1. Find a way to present a general sentence by defining `errors.format`.
2. Find `activerecord.attributes.<model_name>.<attribute_name>`. If there isn’t one and you want to translate it, submit a pull request where you define such a key on GitHub. (See diff below)
3. Validation message translations are under `errors.messages`. However, you can use `%{attribute}` in the translation even it’s not appeared in the source language (en). (See diff below)

Example for tweaking zh\_CN translation as a diff:

> **[Comparing 51b0b5f...2540cb2 · erickguan/discourse](https://github.com/erickguan/discourse/compare/51b0b5f...2540cb2)**
>
> A platform for community discussion. Free, open, simple. - Comparing 51b0b5f...2540cb2 · erickguan/discourse

### Dev notices

1. You can delete those dangling validation translation. See the post below and pull request above.
2. key `activerecord` might be changed. When adding a new validation message, they also need a attribute here to be translated.
3. Those error messages appear in two different place which might be confusing.

[https://meta.discourse.org/t/non-existence-of-strings-in-the-source-code/36206/3?u=fantasticfears](https://meta.discourse.org/t/non-existence-of-strings-in-the-source-code/36206/3)
