Conversation
Codecov Report
@@ Coverage Diff @@
## master #1555 +/- ##
=======================================
Coverage 96.78% 96.78%
=======================================
Files 511 511
Lines 8640 8640
=======================================
Hits 8362 8362
Misses 278 278 |
4dd1a76 to
d4ce6ec
Compare
| config.authorization_handlers = [ExampleAuthorizationHandler] | ||
|
|
||
| # Uncomment this lines to set your preferred locales | ||
| # config.available_locales = %i{en ca es} |
There was a problem hiding this comment.
Since Ruby 2.0 this is equivalent
There was a problem hiding this comment.
It is. But we are enforcing the style I switched to via rubocop.
|
@deivid-rodriguez the second point can be related to #1532, if you want to link it :) |
| # Uncomment this lines to set your preferred locales | ||
| # config.available_locales = [:en, :ca, :es] | ||
| # Change this line to set your preferred locales | ||
| config.available_locales = [:en, :ca, :es] |
There was a problem hiding this comment.
Maybe the problems are the seeds, then? Since the organization created there uses Decidim.available_locales as its own available_locales. Maybe we can change it there?
There was a problem hiding this comment.
You mean using the hardcoded list for the organizations locales, but leaving the full list enabled here? As long as I don't have to fill in 8 locales for each field on every form, sounds good to me! :)
There was a problem hiding this comment.
Yep, I'd change the values in the seeds until we start working on not making all the languages compulsory
| task sanitize_locales: :environment do | ||
| Decidim::Organization.find_each do |organization| | ||
| sanitized_locales = | ||
| organization.available_locales & Decidim.available_locales.map(&:to_s) |
There was a problem hiding this comment.
I'm not sure about this. Shouldn't we update processes, etc in order to fix the locales there too?
There was a problem hiding this comment.
I guess, I didn't know there were other locales in DB.
There was a problem hiding this comment.
If we configure a reasonable set of locales per organization, I don't think we need this at the moment. I'll remove it, ok?
There was a problem hiding this comment.
Now I see what you meant by updating processes. All translations for every text field are saved in DB, of course...
There was a problem hiding this comment.
Yeah, that's what I meant. We would need to update every process/meeting/whatever and remove that language :/
There was a problem hiding this comment.
Well, I'm not sure leaving the translations around could cause any problems. And they would still be there if you reenable the language... :) I can see how the opposite is problematic in the current situation though (adding a new language and every object lacking compulsory translations).
docs/getting_started.md
Outdated
| - [Social providers integration](https://github.com/decidim/decidim/blob/master/docs/social_providers.md): Enable sign up from social networks. | ||
| - [Analytics](https://github.com/decidim/decidim/blob/master/docs/analytics.md): How to enable analytics | ||
| - [Geocoding](https://github.com/decidim/decidim/blob/master/docs/geocoding.md): How to enable geocoding for proposals and meetings | ||
| - [Languages](https://github.com/decidim/decidim/blob/master/docs/languages.md): How to enable configure languages |
There was a problem hiding this comment.
How to configure languages?
|
@mrcasals Your comments make sense to me, it should make this much simpler. I'll update the PR & docs as you suggested. |
Should I keep 32c00fb? Removing locales globally is currently prone to errors (you have to re-seed or use a task like the one I provided here), and provides little value over configuring them per organization. So I'm not even sure about keeping that either, even if it fixes unexpected behavior. |
|
We deliberately don't let system admins modify available locales for an already created organization, because we thought that modifying the locales could give some problems right now (until we do that PR about the locales). As for that commit, I'd ping @beagleknight so he can chime in :) |
|
Oh, I didn't know that... #1127 keeps biting! 😱 |
|
@deivid-rodriguez, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mrcasals and @josepjaume to be potential reviewers. |
d4ce6ec to
98e3e0c
Compare
|
I rebased this PR and removed the parts I was not sure about. Updated the PR description to reflect what's left in there. It's ready for another review pass! |
98e3e0c to
9e9a371
Compare
9e9a371 to
19f5bb0
Compare
Due to the order Rails loads things, locale were not actually configurable via `Decidim.available_locales` at the moment, because when the assignment to Rails native locales was done, customizations had not yet been loaded. This change fixes it by loading locale customizations _before_ setting `config.i18n.available_locales`.
Each test should be responsible for not leaking state.
19f5bb0 to
3628cdd
Compare
|
Anything else left to do here? This makes manual testing a lot easier IMO. |
beagleknight
left a comment
There was a problem hiding this comment.
Looks ok! Let's merge 😄
|
Yuhuuuuu! 🎉 |
* Fix code style of commented configuration * Fix locale configuration Due to the order Rails loads things, locale were not actually configurable via `Decidim.available_locales` at the moment, because when the assignment to Rails native locales was done, customizations had not yet been loaded. This change fixes it by loading locale customizations _before_ setting `config.i18n.available_locales`. * Fix typo * No need to reset locales for every test Each test should be responsible for not leaking state. * A a more reasonable set of locale for sample orgs
| homepage_image: File.new(File.join(__dir__, "seeds", "homepage_image.jpg")), | ||
| default_locale: I18n.default_locale, | ||
| available_locales: Decidim.available_locales, | ||
| available_locales: [:en, :ca, :es], |
There was a problem hiding this comment.
Hi @deivid-rodriguez ! I know this is merged but I am having a few problems because of that 😄 . Do you remember why you hardcoded this values?
The problem I found is when a installation doesn't have English for example, I cannot create a review app because the seeds are creating "invalid" organizations.
There was a problem hiding this comment.
No problem! 😄 I think I am going to change our app generator to include those locales as default because if we leave Decidim.available_locales commented it will use all the locales.
There was a problem hiding this comment.
Sorry about that... 🙏 I can rework another PR that doesn't touch the seed process if you want.
There was a problem hiding this comment.
Heheh, we replied at the same time :) Sounds good to me, sorry for the trouble 😅
There was a problem hiding this comment.
Don't worry! I think I can handle it and it's not a big deal 😄
🎩 What? Why?
This PR fixes several things regarding decidim languages:
Adds docs! 🎉Allows configuring locales. At the moment, by the time decidim's configuration is run, the
config.available_locales = Decidim.available_localesassignment inapplication.rbhas already been run. So custom locales are not picked up. I fixed it by changing the order these are run.Changes generated application locales to be. I finally used those locales not globally but for the sample organizations as suggested by @mrcasals.:en,:ca&:es, instead of all available locales. At the moment, playing around with the generated application is a PITA because until we fix Only require the default locale translations #1127, all languages are required. And the generated application uses all 8 languages by default! Even if Only require the default locale translations #1127 was no longer a problem, I'm not sure we want to generate applications with all languages enabled, since it would be a pretty unrealistic application. I think enabling English + decidim original languages is a good compromise.Makes it easier to remove locales from an app by providing a rake task,decidim:sanitize_locales, that cleans up DB from no longer available locales. Without running this task, decidim can crash after removing locales, because the locales available for each organization might no longer be available.📌 Related Issues
Fixes Add docs about i18n #1439.Doesn't completely fix it, but gets it started.Blocked on Fix decidim dev tasks not being exposed #1554, since decidim can't provide tasks to applications until that one is merged. It's currently built on top of it.That PR was merged.📋 Subtasks
None.
📷 Screenshots (optional)
None.
👻 GIF