Slovak translation - after switching to sk locale Discourse home page is not loaded

(Stanislav Valášek) #1

I want to test Slovak translation before sending a pull request.
I followed the post How to add a new language. I triggered ./launcher restart app and was able to see sk as an option.

BUT when I select and confirm this option, I am getting a blank page.
I checked the browser console logs and the problem starts here:
GET 404 (Not Found)
Now I need a little help how to continue. In that folder is placed this file sk.js.erb.

Content of sk.js.erb is following

//= depend_on ''
//= require locales/i18n
<%= JsLocaleHelper.output_locale(:sk) %>

I18n.pluralizationRules['sk'] = function (n) {
  if (n == 0) return ["zero", "none", "other"];
  if (n == 1) return "one";
  if (n >= 2 && n <= 4) return "few";
  return "other";

Output from git status command:

root@ip-172-31-31-151-app:/var/www/discourse# git status
On branch tests-passed
Your branch is up-to-date with 'origin/tests-passed'.
Untracked files:
(use "git add <file>..." to include in what will be committed)


Here is a full output from the browser console.
browser-console log.txt (1.5 KB)

Thank you for any hints

(Gerhard Schlager) #2

On first glance everything looks fine. Try rebuilding your container instead of just restarting it.

./launcher rebuild app

Or test it within a development environment.

(Stanislav Valášek) #3

hmm, I am getting this error after running ./launcher rebuild app

I, [2015-12-07T22:02:43.264641 #38]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
I18n::InvalidLocale: "sk" is not a valid locale
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'

Is sk locale missing somewhere in ruby gems? should I use sk_SK?

Full log attached:
launcher-rebuild-app.txt (137.1 KB)

(Gerhard Schlager) #4

The errors after the Docker container rebuild where probably caused by missing locale files. I guess they got lost during the rebuild because you added the Slovak locale files by entering the container and adding them manually instead of modifying the app.yml.

I gave it a try in my development environment.
sk seems to be the correct locale. The output from git status looked like this:

modified:   .tx/config
new file:   app/assets/javascripts/locales/sk.js.erb
new file:   config/locales/
new file:   config/locales/
new file:   plugins/poll/config/locales/
new file:   plugins/poll/config/locales/
new file:   public/
new file:   public/
new file:   public/
new file:   public/
new file:   vendor/gems/discourse_imgur/lib/discourse_imgur/locale/

Don’t forget to modify .tx/config and add a mapping from sk_SK (Transifex) to sk (Ruby) when you submit your PR.

(Stanislav Valášek) #5

Thanks a lot Gerhard.

I am new to Docker and Rails but you are probably right. I made an another attempt.

  1. Made a git repo - GitHub - valasek/discourse-slovak.

  2. Modified app.yml after_code: hook like this:

    - exec:
    cd: $home/plugins
    - mkdir -p plugins
    - git clone GitHub - discourse/docker_manager: plugin for use with discourse docker image
    cd: $home
    - git clone GitHub - valasek/discourse-slovak
    - cp discourse-slovak/ /var/www/discourse/config/locales/
    - cp discourse-slovak/ /var/www/discourse/config/locales/
    - cp discourse-slovak/ /var/www/discourse/plugins/poll/config/locales/
    - cp discourse-slovak/ /var/www/discourse/plugins/poll/config/locales/
    - cp discourse-slovak/ /var/www/discourse/public/
    - cp discourse-slovak/ /var/www/discourse/public/
    - cp discourse-slovak/ /var/www/discourse/public/
    - cp discourse-slovak/ /var/www/discourse/public/
    - cp discourse-slovak/sk.js.erb /var/www/discourse/app/assets/javascripts/locales/sk.js.erb
    - cp discourse-slovak/ /var/www/discourse/vendor/gems/discourse_imgur/lib/discourse_imgur/locale/
    - cp discourse-slovak/config /var/www/discourse/.tx/config

3.and run ./launcher rebuild app.

The error I am getting now is:

I, [2015-12-13T23:29:26.036605 #18701]  INFO -- : Writing /var/www/discourse/public/assets/locales/ru-73bd0efccaa29e596449cbb6d038f2b2.js
rake aborted!
NoMethodError: undefined method `delete' for nil:NilClass
  (in /var/www/discourse/app/assets/javascripts/locales/sk.js.erb)

Maybe if anybody wants to help with PR I will be glad.
I have signed Discourse CLA as well.

(Gerhard Schlager) #6

I’m not exactly sure why you’re still getting an error in Docker.
Maybe it’s because of the wrong language code in the yml files. Replace the sk_SK with sk.
Your sk.js.erb isn’t correct either. Take a look at Add Slovak locale · gschlager/discourse@a179bcc · GitHub

What sort of help do you need? I can send a PR if you want.

(Stanislav Valášek) #7

Please send PR. I will be glad. Let me know what else do you need.

(Gerhard Schlager) #8


(Stanislav Valášek) #9

Thank you. We will finish the server translation soon.