How to update translations on running instance of Discourse


#1

Hello, I’ve translated most of the two yaml files to Hebrew and I’d like to test them. I have a running instance on Digital Ocean (via docker). How can I put it there?

Also, to add it to the repo should I just do a pull request?

Thanks


(Kane York) #2

You should be doing the translation work on Transifex: https://www.transifex.com/projects/p/discourse-pt-br/

The team regularly pulls the translations from there.


(Erick Guan) #3

I suggest you can put them on Transifex and wait for pull.

If you want to test on Docker. ./launcher ssh app and put these file under the discourse /config/locale.


#4

@riking I’ve been translating the yaml files directly as I was working on an offline machine at the time. I will try to import those.

@fantasticfears I tried doing that but Hebrew doesn’t appear in the locales settings, and I get 502 after doing ./launcher/ restart app


#5

OK. I’ve been playing with this, and I can’t get the translations there. This is the addition to app.yml:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
        cd: $home/config/locales
        cmd:
          - wget https://gist.githubusercontent.com/anonymous/8442e82f6d8c12ad2ecc/raw/68d58994565360e840d9ea670e1fe13d88c49dd6/client.he.yml
          - wget https://gist.githubusercontent.com/anonymous/34350c2ded6d0c1fa80b/raw/b3d39f1e4ed0286d764c547a83d5e4ecafe0e265/server.he.yml
        cd: $home/app/assets/javascripts/locales
        cmd:
          - wget https://gist.githubusercontent.com/anonymous/881ad3e381c4e042378f/raw/4bd69c0e04ba27b422fdb7ba5798a7c81417816e/he.js.erb

Running ./launcher rebuild app results in this error:

/pups/lib/pups/exec_command.rb:85:in `spawn': cd /var/www/discourse && sudo -E -u discourse bundle exec rake assets:precompile failed with return #<Process::Status: pid 273 exit 1> (RuntimeError)
    from /pups/lib/pups/exec_command.rb:55:in `block in run'
    from /pups/lib/pups/exec_command.rb:53:in `each'
    from /pups/lib/pups/exec_command.rb:53:in `run'
    from /pups/lib/pups/command.rb:6:in `run'
    from /pups/lib/pups/config.rb:85:in `block (2 levels) in run_commands'
    from /pups/lib/pups/config.rb:76:in `each'
    from /pups/lib/pups/config.rb:76:in `block in run_commands'
    from /pups/lib/pups/config.rb:75:in `each'
    from /pups/lib/pups/config.rb:75:in `run_commands'
    from /pups/lib/pups/config.rb:71:in `run'
    from /pups/lib/pups/cli.rb:31:in `run'
    from /pups/bin/pups:8:in `<main>'
4fbb7873cdd02256c78b0d2d63fe15c6dd7551b93d285bf29455a0c15796866a
FAILED TO BOOTSTRAP

So I used ssh to log into the container and ran RAILS_ENV=production bundle exec rake assets:precompile under the discourse user, which ran smoothly but then I got a blank page on the site, so I looked at production_error.log and it said:

[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.4/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/abstract_controller/base.rb:136:in `process'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:44:in `process'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:108:in `block in profile_method'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal.rb:195:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal.rb:231:in `block in action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:80:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:48:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/mapper.rb:44:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/journey/router.rb:71:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/journey/router.rb:59:in `each'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/journey/router.rb:59:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/routing/route_set.rb:674:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-protection-1.5.2/lib/rack/protection/frame_options.rb:31:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/builder.rb:59:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
[RAILS_ROOT]/lib/middleware/anonymous_cache.rb:104:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/flash.rb:241:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/cookies.rb:486:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/message_bus-0.9.4/lib/message_bus/rack/middleware.rb:55:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.4/lib/active_record/query_cache.rb:36:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/callbacks.rb:373:in `_run__942292334021739017__call__callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/callbacks.rb:80:in `run_callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:38:in `call_app'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:20:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:68:in `block in tagged'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:26:in `tagged'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:68:in `tagged'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:20:in `call'
[RAILS_ROOT]/config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
[RAILS_ROOT]/config/initializers/silence_logger.rb:19:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/request_id.rb:21:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiler.rb:300:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/engine.rb:511:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application.rb:97:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:30:in `method_missing'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:572:in `process_client'
[RAILS_ROOT]/lib/middleware/unicorn_oobgc.rb:95:in `process_client'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:666:in `worker_loop'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:521:in `spawn_missing_workers'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:140:in `start'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/bin/unicorn:126:in `&lt;top (required)&gt;'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `&lt;main&gt;'</backtrace>
  <message>"he" is not a valid locale</message>
  <url>...</url>
  <exception-class>I18n::InvalidLocale</exception-class>
</hash>
<hash>
  <date type="dateTime">2014-04-19T18:43:42+00:00</date>
  <guid>feaf5ca4-c706-4d00-b3d2-994a51fbb482</guid>
  <user-id type="integer">2</user-id>
  <parameters>{"controller":"list","action":"latest"}</parameters>
  <action>latest</action>
  <controller>list</controller>
  <backtrace>[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/i18n-0.6.9/lib/i18n.rb:288:in `enforce_available_locales!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/i18n-0.6.9/lib/i18n/config.rb:11:in `locale='
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_view/lookup_context.rb:226:in `locale='
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:28:in `locale='
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/i18n-0.6.9/lib/i18n.rb:35:in `locale='
[RAILS_ROOT]/app/controllers/application_controller.rb:124:in `set_locale'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/callbacks.rb:387:in `_run__1809777749290086093__process_action__callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/callbacks.rb:80:in `run_callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/abstract_controller/callbacks.rb:17:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal/rescue.rb:29:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `block in instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action'

So I googled it and got to this page:
https://github.com/rails/rails/issues/13164

I think its worth mentioning I have never seen more than Hello World in Ruby, not to mention Rails, so I have no idea if this is even related, but I gave a shot to adding i18n.config.enforce_available_locales = false in config/environments/production.rb.
Not getting a blank page anymore, but setting locale as he has no effect.

Help?

Thanks :smiley:

P.S, YAML files were validated using http://yamllint.com/

client.he.yml
server.he.yml
he.js.erb

UPDATE:
Ok, so it seems like server translations are fine, just canceled a backup and Discourse showed a Hebrew message. Forum UI is still English, though.

UPDATE #2:
./launcher restart app did it, everything shows Hebrew now. It seems like the addition of i18n.config.enforce_available_locales = false in config/environments/production.rb solved it. Is it OK using it? Should it be in the official repo?


(Kai) #6

I wanted to update a locale on a running system, as well. It wasn’t necessary to change the config in production.rb, though. All I did is this:

./launcher ssh app
vim /var/www/discourse/config/locales/client.de.yml
sudo -u discourse RAILS_ENV=production bundle exec rake assets:precompile
./launcher restart app

(Michael) #7

You can edit yml files with your favorite editor using sshfs from any computer like this:

sshfs <host_with_docker>:/var/lib/docker/aufs/mnt/<CID>/var/www/discourse/config/locales/ <local_path> -o reconnect -o idmap=user

You can view CID on docker host:

docker inspect -f '{{.Id}}' app

I had some problems with encodings trying to edit cyrillic yml files using vim and nano on the server. So I just mount folder with locales through sshfs and edit files “locally” with sublime.