# Discobot translation missing error

**URL:** https://meta.discourse.org/t/discobot-translation-missing-error/64429
**Category:** Support
**Created:** [June 13, 2017, 3:21pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429 "2017-06-13T15:21:55Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jidetheblogger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jidetheblogger/32/73213_2.png) [@jidetheblogger](https://meta.discourse.org/u/jidetheblogger)
#### Post date: [June 13, 2017, 3:21pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/1 "2017-06-13T15:21:55Z")

</div>

New users seeing this :

```plaintext
 translation missing: en.discourse_narrative_bot.new_user_narrative.hello.message

If you’d like to learn more, select below and bookmark this private message. If you do, there may be a :gift: in your future!

```

My current template is :

```plaintext
Thanks for joining %{site_name}, and welcome! 

- I’m only a robot, but [our friendly staff](/about) are also here to help if you need to reach a person.

- For safety reasons, we temporarily limit what new users can do. You’ll gain new abilities (and [badges](/badges)) as we get to know you.

- We believe in [civilized community behavior](/guidelines) at all times.

```

Pls, how can i fix it?

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [June 13, 2017, 3:32pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/2 "2017-06-13T15:32:26Z")

</div>

Which version are you running? Is your site in english? [The translation is there](https://github.com/discourse/discourse/blob/master/plugins/discourse-narrative-bot/config/locales/server.en.yml#L152). Can you see it in Admin \> Customize \> Text Content?

 ![](https://global.discourse-cdn.com/meta/original/3X/c/0/c0292ce2664da7a227f08f206d8819a4345aeadd.png)

---

<div class="post-metadata">

### Author: ![jidetheblogger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jidetheblogger/32/73213_2.png) [@jidetheblogger](https://meta.discourse.org/u/jidetheblogger)
#### Post date: [June 13, 2017, 3:38pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/3 "2017-06-13T15:38:26Z")

</div>

- Yes, [site](https://planet.ogbongeblog.com) is in english.
- Running latest version v1.9.0.beta2 +7. I upgraded this morning.

---

<div class="post-metadata">

### Author: ![jidetheblogger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jidetheblogger/32/73213_2.png) [@jidetheblogger](https://meta.discourse.org/u/jidetheblogger)
#### Post date: [June 13, 2017, 3:55pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/4 "2017-06-13T15:55:21Z")

</div>

FIXED

I changed %{site\_name}, to %{title},

and confirmed it by creating a new account. Thanks.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 13, 2017, 11:02pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/5 "2017-06-13T23:02:32Z")

</div>

Hmm should this say “translation missing”? The error seems to be

> Thanks for joining %{site\_name}, and welcome!

versus

> Thanks for joining %{title}, and welcome!

Perhaps a better result would be

> translation **error** : en.discourse\_narrative\_bot.new\_user\_narrative.hello.message

is that possible @tgxworld?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 13, 2017, 11:36pm UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/6 "2017-06-13T23:36:09Z")

</div>

That is the message returned by the i18n gem when the given parameters do not match the expected parameters in the translation string. If we want to change the message we’ll have to propose it to the gem which might not be worth the trouble. Instead, I’m more inclined to fix the root cause here by adding a validation to check the same parameters are used in the customized string.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 14, 2017, 12:03am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/7 "2017-06-14T00:03:02Z")

</div>

I think the upstream fix is superior in this case and would help more folks, bad error messages are very very dangerous.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 14, 2017, 12:10am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/8 "2017-06-14T00:10:39Z")

</div>

I don’t think the message is incorrect here. What is happening here is that the user is asking for a translation string that takes in the `site_name` params which isn’t defined so translation missing is correct here IMO.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 14, 2017, 12:12am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/9 "2017-06-14T00:12:47Z")

</div>

I don’t agree. The translation is looking for key value pairs, the substitutions are at best optional parameters. In this case the translation is present according to the key value pair but missing parameters.

It is a very misleading error message… if it’s too hard to fix right, then so be it I guess.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [June 14, 2017, 12:20am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/10 "2017-06-14T00:20:12Z")

</div>

Is there any chance that these translation missing errors could also trigger a warning message to staff? In the case of emails, it might be best to suppress emails containing an error message as proposed here:

> [@"translation missing" being delivered via email](https://meta.discourse.org/t/translation-missing-being-delivered-via-email/60667/13):
>
> Since it is rather easy to break custom text (in the sense that it will fail to render due to missing translation), it would be great if there could be a security mechanism that prevents emails from being sent out if they contain translation missing: and instead send an error message to the site admin?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 14, 2017, 12:22am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/11 "2017-06-14T00:22:07Z")

</div>

> [@codinghorror](#):
>
> the substitutions are at best optional parameters.

The substitutions are not optional in the case of translation strings with params.

> [@codinghorror](#):
>
> if it’s too hard to fix right

I don’t necessary think it should be called an error but I do think that `translation missing` message can be improved to display the keys that are missing. Also the error that the gem raises is named `I18n::MissingTranslationData` so the message should probable have been `translation data missing` instead of just `translation missing`.

I just re-read through the guides and a nice thing that we can add is to test the user’s customized string first before allowing it to be saved. We can do something like

```plaintext
[13] pry(main)> begin
[13] pry(main)* I18n.t('test.same_key', some: 'haha', raise: true)  
[13] pry(main)* rescue I18n::MissingTranslationData  
[13] pry(main)* puts "o noes you didn't customize the text correctly"  
[13] pry(main)* end  
o noes you didn't customize the text correctly

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 14, 2017, 12:24am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/13 "2017-06-14T00:24:25Z")

</div>

Yes translation data missing works much better than translation missing! The messages need to be significantly different.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 15, 2017, 4:12am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/14 "2017-06-15T04:12:32Z")

</div>

Created an issue in

[https://github.com/svenfuchs/i18n/issues/375](https://github.com/svenfuchs/i18n/issues/375)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 16, 2017, 4:23am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/15 "2017-06-16T04:23:10Z")

</div>

Text customization will now check for right interpolation keys

[https://github.com/discourse/discourse/commit/b5ec241716b6fb09598e9e82080a3b5a2f645473](https://github.com/discourse/discourse/commit/b5ec241716b6fb09598e9e82080a3b5a2f645473)

---

<div class="post-metadata">

### Author: ![lynaghk](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lynaghk](https://meta.discourse.org/u/lynaghk)
#### Post date: [August 25, 2017, 12:02am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/17 "2017-08-25T00:02:12Z")

</div>

What’s the reasoning for enforcing that all interpolation keys are used in the message?  
(The [missing\_keys](https://github.com/discourse/discourse/commit/b5ec241716b6fb09598e9e82080a3b5a2f645473#diff-0017182e3f9a48f252467f22c1f587aeR49) check in the commit.)

I ran into this when updating an email template on my forum — I cannot save the template unless I actually include all of the variables in the text.

Is there any way to turn off this validation from the admin interface?

Would be happy to contribute a pull request, but I wanted to check here to get some context/discussion on appropriate fix first. Thanks!

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 25, 2017, 12:30am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/18 "2017-08-25T00:30:04Z")

</div>

I can’t speak to the reason for requiring all variables, @tgxworld will need to, but you should be able to get around that by using HTML comments. For example `<!-- %{site_name} -->`.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 25, 2017, 12:32am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/19 "2017-08-25T00:32:26Z")

</div>

Good idea, I’m not 100% sure what will happen in an email if you do that, I’d definitely test it out.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 25, 2017, 12:33am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/20 "2017-08-25T00:33:25Z")

</div>

I saw that suggestion [here](https://meta.discourse.org/t/interpolation-key-site-name-required-in-automated-messages/65653/2), which is marked as a solution by the OP so I’m _assuming_ it works. (Emphasis on assume)

> [@Interpolation key "site\_name" required in automated messages](https://meta.discourse.org/t/interpolation-key-site-name-required-in-automated-messages/65653/2):
>
> I haven’t tried, but does it work to hide the required %{site\_name} bit in an html comment? This is an automated message \<!-- %{site\_name} --\> to let you know that…

---

<div class="post-metadata">

### Author: ![lynaghk](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lynaghk](https://meta.discourse.org/u/lynaghk)
#### Post date: [August 25, 2017, 12:45am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/21 "2017-08-25T00:45:13Z")

</div>

I considered that, but it won’t “resolve” the issue for email subject lines.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 25, 2017, 1:50am UTC](https://meta.discourse.org/t/discobot-translation-missing-error/64429/22 "2017-08-25T01:50:12Z")

</div>

> [@lynaghk](#):
>
> What’s the reasoning for enforcing that all interpolation keys are used in the message?
> 
> (The missing\_keys check in the commit.)

The idea is to help users check that they didn’t leave out any of the interpolation keys from the original translation. I didn’t think that some users would want to remove them completely. This isn’t critical but I added it along with the `invalid_keys` check which was the more critical one that would prevent users from shooting themselves in the foot. Unfortunately, that has since been reverted while I think of a solution for [this hash](https://github.com/discourse/discourse/blob/e8a2aaafebb93675bb3a39314920b96dee314025/app/mailers/user_notifications.rb#L455-L481) which mixes parameters for the translations and options used to decide what type of emails to send.

[Next page](https://meta.discourse.org/t/discobot-translation-missing-error/64429.md?page=2)
