Skip to content

Locale sanity#1330

Merged
josepjaume merged 9 commits intodecidim:masterfrom
deivid-rodriguez:locale_sanity
May 30, 2017
Merged

Locale sanity#1330
josepjaume merged 9 commits intodecidim:masterfrom
deivid-rodriguez:locale_sanity

Conversation

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

🎩 What? Why?

Just a quick proof of concept of how ensuring complete :es, :ca and :en would look. This would partially fix translation issues for the current installations, so we can deal with the versioning stuff discussed at a later stage.

Enabling the check for :es and :ca locales.

This change (ad8cbda) detected some missing translations in decidim-core. At a first glance, they look true positives to me, but I'm not sure:

Missing translations (16) | i18n-tasks v0.9.13
+--------+---------------------------------------+----------------------------------+
| Locale | Key                                   | Value in other locales or source |
+--------+---------------------------------------+----------------------------------+
|   ca   | pages.home.statistics.meetings_count  | en Meetings                      |
|   ca   | pages.home.statistics.processes_count | en Processes                     |
|   ca   | pages.home.statistics.projects_count  | en Projects                      |
|   ca   | pages.home.statistics.proposals_count | en Proposals                     |
|   ca   | pages.home.statistics.results_count   | en Results                       |
|   ca   | pages.home.statistics.users_count     | en Users                         |
|   ca   | pages.home.statistics.votes_count     | en Votes                         |
|   en   | pages.home.statistics.processes       | nl Processen                     |
|   en   | pages.home.statistics.users           | nl Gebruikers                    |
|   es   | pages.home.statistics.meetings_count  | en Meetings                      |
|   es   | pages.home.statistics.processes_count | en Processes                     |
|   es   | pages.home.statistics.projects_count  | en Projects                      |
|   es   | pages.home.statistics.proposals_count | en Proposals                     |
|   es   | pages.home.statistics.results_count   | en Results                       |
|   es   | pages.home.statistics.users_count     | en Users                         |
|   es   | pages.home.statistics.votes_count     | en Votes                         |
+--------+---------------------------------------+----------------------------------+
Enabling dynamic guessing.

This change (e454c48) led to nothing new, so I'm not sure whether it's a good change or not.

📌 Related Issues

📋 Subtasks

None

📷 Screenshots (optional)

None

👻 GIF

forrest

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

If this was to be included, it'd be nice to have an easy way to push translations to crowdin from the dev environment. Is this something crowdin provides?

@beagleknight
Copy link
Copy Markdown
Contributor

I summon @josepjaume because I'm not really sure about Crowdin 😄 !

@josepjaume
Copy link
Copy Markdown
Contributor

I think so, but unsure of how it works with branches.

Maybe we could do this check prior to releasing a version? It's kinda nice being able to only include english translations and then translating them via crowdin. What we don't want is released versions with missing locales.

Does this make sense to you?

Copy link
Copy Markdown
Contributor

@oriolgual oriolgual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I'm against this. Initially we had a similar config but we moved Catalan & Spanish two Crowdin. The reasoning behind this is that you can only have one source of truth, and that's the English locales.

I'd be OK with having a rake tasks that checks other locales, but that would be used in each installation, not in Decidim.

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

@josepjaume Makes sense to me! I can change the PR so that the full task is not run by default.

Ideally it would pickup locales from an env variable so it can be run against arbitrary locales, and it should be runnable inside the main repo (to ensure completeness of official locale before releasing) and from installations (so non official locales can do something about it as well).

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

@oriolgual So we wouldn't add nothing compulsory, just enhance the set of tools installations and core can use to enforce locale completeness. Makes sense?

@josepjaume
Copy link
Copy Markdown
Contributor

Is this progressing or can we close it?

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I was kind of expecting some more input from @oriolgual before proceeding further.

@josepjaume
Copy link
Copy Markdown
Contributor

Okay sorry! I had my PR grooming hat on and didn't actually read the entire conversation.

@oriolgual
Copy link
Copy Markdown
Contributor

Ooops, my bad, yes that makes sense @deivid-rodriguez!

@codecov
Copy link
Copy Markdown

codecov bot commented May 16, 2017

Codecov Report

Merging #1330 into master will decrease coverage by 4.8%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1330      +/-   ##
==========================================
- Coverage   95.42%   90.62%   -4.81%     
==========================================
  Files         420      323      -97     
  Lines        7213     5588    -1625     
==========================================
- Hits         6883     5064    -1819     
- Misses        330      524     +194
Impacted Files Coverage Δ
...mments/lib/decidim/comments/mutation_extensions.rb 25% <0%> (-75%) ⬇️
...-comments/lib/decidim/comments/query_extensions.rb 36.36% <0%> (-63.64%) ⬇️
.../app/services/decidim/proposals/proposal_search.rb 33.33% <0%> (-62.97%) ⬇️
...trollers/decidim/proposals/proposals_controller.rb 36.53% <0%> (-59.62%) ⬇️
...dim/proposals/admin/proposal_answers_controller.rb 42.85% <0%> (-57.15%) ⬇️
...helpers/decidim/proposals/proposal_votes_helper.rb 43.75% <0%> (-56.25%) ⬇️
.../decidim/proposals/abilities/process_admin_user.rb 48.27% <0%> (-51.73%) ⬇️
...p/commands/decidim/meetings/admin/close_meeting.rb 50% <0%> (-50%) ⬇️
...p/models/decidim/proposals/abilities/admin_user.rb 50% <0%> (-50%) ⬇️
...ers/decidim/proposals/proposal_votes_controller.rb 52.63% <0%> (-47.37%) ⬇️
... and 139 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29be570...e097f17. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov bot commented May 16, 2017

Codecov Report

Merging #1330 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1330   +/-   ##
=======================================
  Coverage   95.42%   95.42%           
=======================================
  Files         426      426           
  Lines        7342     7342           
=======================================
  Hits         7006     7006           
  Misses        336      336

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0a9496...2abc01f. Read the comment docs.

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I pushed a proof of concept of what I'm proposing to do!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

@josepjaume Did you use this task before the last release? When I pushed the last changes, the task was detecting some missing translations, but now it's all greeny! 🎉 🎉

$ bundle exec rake check_locale_completeness
warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 2.47 seconds (files took 0.48515 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.34599 seconds (files took 0.493 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 2.59 seconds (files took 0.51189 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.02507 seconds (files took 0.4772 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.1163 seconds (files took 0.51795 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.41022 seconds (files took 0.43737 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.91211 seconds (files took 0.4801 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.41916 seconds (files took 0.43802 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.57575 seconds (files took 0.44598 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.73293 seconds (files took 0.57483 seconds to load)
3 examples, 0 failures

warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
...

Finished in 0.01993 seconds (files took 0.44594 seconds to load)
3 examples, 0 failures

@oriolgual
Copy link
Copy Markdown
Contributor

@deivid-rodriguez I'm not sure I've understand this: do you run the rake task from decidim root or in a decidim installation like Barcelona? I meant to do it in a installation, I don't think we should block a release because some language is missing a locale (even catalan or spanish).

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

It can be run from both. If run from decidim's root, it checks official locales (en, ca, es). If run from an installation, it checks application locales.

I added the "root check" to the release task because I think that's what @josepjaume suggested. But I can remove that bit.

@oriolgual
Copy link
Copy Markdown
Contributor

@deivid-rodriguez can you document how to run the task from an installation? Maybe we can add it to the getting started guide.

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

@oriolgual I added some docs in 1a4009c!

task :check_locale_completeness do
DECIDIM_GEMS.each do |gem_name|
Dir.chdir("#{File.dirname(__FILE__)}/decidim-#{gem_name}") do
system({ "ENFORCED_LOCALES" => "en,ca,es" }, "rspec spec/i18n_spec.rb")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we make this configurable? Either via params to the task or using the app configured locales?

Copy link
Copy Markdown
Contributor Author

@deivid-rodriguez deivid-rodriguez May 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the task supposed to be run from decidim's root. In that case, I wanted to hardcode it to just check the "officially supported" locales. I could make it configurable but I'm not sure if it's worth the effort...

Note that if the task is run from an app, the app locales are used instead, not via this task, but via https://github.com/decidim/decidim/pull/1330/files#diff-c3eb346890858ca91acb2f677044cdd1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry about that, I didn't realise it was two different things! About the official maintained locales: I'm not sure if we should even include Catalan & Spanish, isn't it a bit arbitrary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! Yes, it's arbitrary. So there's two ideas here:

  • One is trying to keep locales in core that are currently 100% complete, 100% complete. This would account for the concept of "officially supported locales". Since I guess most core developers right now speak all three languages and most current installations include ca and es, choosing es, ca and en as official locales seems natural. But yes, this concept of official locales is a bit arbitrary and would probably no longer make sense once/if we extract decidim-i18n to a separate library.

  • The other one is to allow installations to check their own locales. I think there's no doubts about this, we all want it, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, all makes sense. Let's go with it now and if we need to adjust in the future we'll do it! :shipit:

oriolgual
oriolgual previously approved these changes May 22, 2017
With colors and all.
Currently `rake development_app` generates a development app with all
locales supported by decidim. Since at the moment is compulsory to
introduce all locale information in forms, it's very tedious to make
manual tests using this app. So I changed it to use the same the test
app uses.
@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I rebased this PR on top of latest master. I'd like to get this in, specifically for 8688bfc. I usually play around with the example app, but at the moment it is generated with 7 different locales. That, in combination with #1127, makes admin forms pretty unusable.

Also fixed a new codeclimate style issue. That, and the fact that the hound check is stuck leads to the question: do we even need/want hound at all?

@oriolgual
Copy link
Copy Markdown
Contributor

We don't need Hound with CodeClimate now, we're actually talking about this!

@josepjaume
Copy link
Copy Markdown
Contributor

Nice! Merging this in!

@josepjaume josepjaume merged commit e8bdafe into decidim:master May 30, 2017
@deivid-rodriguez deivid-rodriguez deleted the locale_sanity branch May 30, 2017 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants