Error In changing site texts

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>'
3 Likes

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

1 Like

My discourse language is fa_IR, This happens after I try to change the text.
Sometimes changing text made errors, especially when there is variable in text.

I think some variables changed over time but they are still used in old translations. Like {site_title} and {site_name} or {base_url} and {basePath} or {base_path}.

It may not be bad to show English text as an explanation for the translation, bellow the change text box when discourse using a different local.

2 Likes

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?

3 Likes

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

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
2 Likes

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.

6 Likes

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.

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

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

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

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)>
2 Likes

Thanks! That helped a lot. The error has been fixed in https://github.com/discourse/discourse/commit/d516e492a4281c10e3851f0043e2ff2e2196fdf6

3 Likes