# Error In changing site texts

**URL:** https://meta.discourse.org/t/error-in-changing-site-texts/126039
**Category:** Bug
**Created:** [August 17, 2019, 7:22am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039 "2019-08-17T07:22:43Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 17, 2019, 7:22am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/1 "2019-08-17T07:22:43Z")

</div>

Hi,  
Today I’m trying to change some of the site text in the admin panel. when I click save changes I get server error 500.  
After that every time I search for text id or text body I got server error 500.

_I think translated text contains “ **{{count}}** ” keyword._

My discourse is up to date and below is log information:

**Env:**

```
REQUEST_URI	/admin/customize/site_texts?q=off_
REQUEST_METHOD	GET

```

**Info:**

```
TypeError (no implicit conversion of Symbol into Integer)
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:172:in `[]'

```

**Backtrace:**

```
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:172:in `[]'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:172:in `block in fix_plural_keys'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:171:in `map'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:171:in `fix_plural_keys'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:153:in `block in find_translations'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:151:in `each'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:151:in `find_translations'
/var/www/discourse/app/controllers/admin/site_texts_controller.rb:30:in `index'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/base.rb:194:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:132:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/callbacks.rb:41:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb:22:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/abstract_controller/base.rb:134:in `process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/rendering.rb:32:in `process'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/mini_profiler/profiling_methods.rb:104:in `block in profile_method'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb:191:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal.rb:252:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:34:in `serve'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/mapper.rb:48:in `serve'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:52:in `block in serve'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:35:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/journey/router.rb:35:in `serve'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:840:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.5/lib/rack/protection/frame_options.rb:31:in `call'
/var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/tempfile_reaper.rb:15:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/conditional_get.rb:25:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/head.rb:12:in `call'
/var/www/discourse/lib/content_security_policy/middleware.rb:12:in `call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:220:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:232:in `context'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:226:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:98:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/logster-2.3.1/lib/logster/middleware/reporter.rb:30:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in `call_app'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/rack/logger.rb:28:in `call'
/var/www/discourse/config/initializers/100-quiet_logger.rb:18:in `call'
/var/www/discourse/config/initializers/100-silence_logger.rb:31:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/var/www/discourse/lib/middleware/enforce_hostname.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/mini_profiler/profiler.rb:281:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/message_bus-2.2.2/lib/message_bus/rack/middleware.rb:57:in `call'
/var/www/discourse/lib/middleware/request_tracker.rb:169:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb:190:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb:190:in `method_missing'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:68:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `call'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:605:in `process_client'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:700:in `worker_loop'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:548:in `spawn_missing_workers'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/unicorn-5.5.1/lib/unicorn/http_server.rb:144:in `start'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/unicorn-5.5.1/bin/unicorn:128:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.6.0/bin/unicorn:23:in `<main>'

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 21, 2019, 4:22am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/2 "2019-08-21T04:22:04Z")

</div>

I am not getting a repro here, this could be a broken translation. What is your locale?

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 21, 2019, 5:27am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/3 "2019-08-21T05:27:57Z")

</div>

My discourse language is fa\_IR. This occurs after I attempt to change the text.  
Sometimes, changing the text causes errors, especially when there are variables in the text.

I believe some variables have changed over time but are still used in older translations, such as {site\_title} and {site\_name}, or {base\_url}, {basePath}, and {base\_path}.

It might not be a bad idea to display the English text as an explanation for the translation below the text change box when Discourse is using a different locale.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 21, 2019, 7:01am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/4 "2019-08-21T07:01:48Z")

</div>

Yeah my guess is that something is broken in the translation, can you report back once you switch to english. Can you help repair the strings in transifex?

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 21, 2019, 7:58am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/5 "2019-08-21T07:58:49Z")

</div>

> [@sam](#):
>
> can you report back once you switch to english.

Honestly, I can’t use English because of my discourse is live and many users use it.

> [@sam](#):
>
> Can you help repair the strings in transifex?

Yes, I’m happy to help repair Persian translation. because there are so many mistakes in this language. we edit our discourse instance site texts and customize it. I can correct some of the common mistakes I see in my discourse over time in transifex.

* * *

The text customizing page in Discourse is very simple design and it is not bad to spend a little more time on this great feature.

Changes like:

- Display default English text for each item when customizing texts
- Displays the community suggestion in the selected local for each item when customizing texts
- Suggest better translation to community in place
- Ability to change translations in texts stored in DB such as system messages
- Displays a list of allowed variables that can be used in the text when customizing texts

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 21, 2019, 8:08am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/6 "2019-08-21T08:08:21Z")

</div>

I am unable to repro a search for `off_` breaking Discourse with fa\_IR set. Are you sure you are on latest.

@gerhard is this a bug in `fix_plural_keys` should it be more conservative. I guess `I18n.t(key, locale: :en)` could in theory return a non plural here:

> <https://github.com/discourse/discourse/blob/719a93c312b9caa6c71de22d67f1ce1a78c1c8b2/app/controllers/admin/site_texts_controller.rb#L170-L170>

At a minimum if we make this a bit more multi line we will be able to see what exploded.

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 21, 2019, 8:18am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/7 "2019-08-21T08:18:10Z")

</div>

My Discourse instance is up to date. If you need a specific log or report to debug, Let me send you. We can also give you remote access or administrative privilege for further investigate.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [August 28, 2019, 2:44pm UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/10 "2019-08-28T14:44:46Z")

</div>

@nildarar I’d like to figure out what’s causing that error. Could you please run the following and post the output?

```plaintext
cd /var/discourse
./launcher enter app
rails c

TranslationOverride.where("translation_key LIKE '%off_%'").pluck(:locale, :translation_key, :value)

```

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 29, 2019, 4:54am UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/11 "2019-08-29T04:54:29Z")

</div>

> [@gerhard](#):
>
> Could you please run the following and post the output?

Thanks for your support. I ran this command and got this output:

```
[1] pry(main)> TranslationOverride.where("translation_key LIKE '%off_%'").pluck(:locale, :translation_key, :value)
=> [["fa_IR", "post_action_types.off_topic.title", "ارتباطی به موضوع گپ یا دسته‌بندی انتخابی ندارد"],
 ["fa_IR", "js.post.actions.undo.off_topic", "برداشتن پرچم"],
 ["fa_IR", "js.post.actions.by_others.off_topic.one", "{{count}} کاربر این مورد را خارج از بحث گزارش کردند"],
 ["fa_IR", "post_action_types.off_topic.long_form", "این موضوع را به عنوان خارج از موضوع پرچم بزن"],
 ["fa_IR", "js.post.actions.people.off_topic", "به عنوان خارج از موضوع گپ پرچم‌گذاری شده"],
 ["fa_IR", "js.post.actions.by_you.off_topic", "شما این نوشته را جهت بررسی موضوعی به مدیران گزارش دادید."],
 ["fa_IR", "js.composer.drafts_offline", "پیش‌نویس آفلاین"],
 ["fa_IR", "js.flagging.official_warning", "ارسال اخطار رسمی"],
 ["fa_IR", "js.flagging.formatted_name.off_topic", "ارتباطی به موضوع گپ یا دسته‌بندی انتخابی ندارد"],
 ["fa_IR", "post_action_types.off_topic.short_description", "ارتباطی به موضوع گپ یا دسته‌بندی انتخابی ندارد"],
 ["fa_IR", "post_action_types.off_topic.description", "این نوشته مشکلی نداره ولی به موضوع گپ یا دسته‌بندی انتخاب شده مرتبط نیست، بهتره به گپ دیگه‌ای منتقل بشه یا در دسته‌بندی درست قرار بگیره."]]
[2] pry(main)>

```

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [August 29, 2019, 3:43pm UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/12 "2019-08-29T15:43:43Z")

</div>

Thanks! That helped a lot. The error has been fixed in [FIX: An overridden text of a non-existent plural key resulted in error · discourse/discourse@d516e49 · GitHub](https://github.com/discourse/discourse/commit/d516e492a4281c10e3851f0043e2ff2e2196fdf6)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [August 29, 2019, 3:43pm UTC](https://meta.discourse.org/t/error-in-changing-site-texts/126039/13 "2019-08-29T15:43:50Z")

</div>


