Skip to content

Adding dropdown option to locales list#6462

Merged
ivan-mr merged 10 commits intodevelopfrom
adding_dropdown_option_to_locales
Sep 15, 2020
Merged

Adding dropdown option to locales list#6462
ivan-mr merged 10 commits intodevelopfrom
adding_dropdown_option_to_locales

Conversation

@anaghavl
Copy link
Copy Markdown
Contributor

@anaghavl anaghavl commented Sep 2, 2020

Adding an option to display locales in dropdown if the total number of locales are more than 4.

Screenshot 2020-09-02 at 1 59 22 PM

Screenshot 2020-09-02 at 6 47 29 PM

When the default locale isn't filled out,
Screenshot 2020-09-14 at 11 38 39 PM

@mrcasals
Copy link
Copy Markdown
Contributor

mrcasals commented Sep 7, 2020

Code looks good to me, I'm deploying it to a staging app to check it out!

@mrcasals
Copy link
Copy Markdown
Contributor

mrcasals commented Sep 7, 2020

Hi @decidim/product! We've discussed this issue via chat previously, but just in case here's a reminder of the problem:

A client wants an installation with a lot of languages (>10 languages). For translatable fields, we currently use tabs, but this solution does not scale for a lot of languages. With this PR we propose useing a dropdown instead of tabs to select the correct language. Tabs will appear if an installation has 4 or less languages. If an installation has 5 or more languages, dropdowns will appear:

image

Note that the screenshot has multiple English locales. This is due to a translation problem, some languages don't have the correct name set up and they show "English" instead of the correct one. We've setup a staging application for you to try this feature out:

https://decidim-staging-pr-158.herokuapp.com/admin/participatory_processes/dolores-dolorum/edit

If you approve its behavior, then we'll ask for tech reviews!

mrcasals
mrcasals previously approved these changes Sep 8, 2020
@carolromero
Copy link
Copy Markdown
Member

@mrcasals looks good! Since you are with it, could you correct the error in the language names as well? 🙏
Thanks!

@mrcasals
Copy link
Copy Markdown
Contributor

mrcasals commented Sep 8, 2020

@carolromero I suspect it's not an actual error, but keys not being (yet) translated. When a key is not translated in a given language, the default one (the one in English) appears. That's why we get "English" here. Apart from that, that'd be something to be done on Crowdin 😄

@decidim/core can you review this, please? 😄

@mrcasals mrcasals self-assigned this Sep 8, 2020
@mrcasals mrcasals requested a review from a team September 8, 2020 09:40
@oriolgual
Copy link
Copy Markdown
Contributor

@tramuntanal could you please take a look at this?

@tramuntanal
Copy link
Copy Markdown
Contributor

Hi @decidim/product I don't know if this change is usable when the form has errors in some language. How will it be rendered? I think that it will be very difficult for the user to note that there's a mandatory translation missing for example..

@anaghavl how does this PR solves this situation?

@mrcasals mrcasals force-pushed the adding_dropdown_option_to_locales branch from ea0b3dc to 4fbe87e Compare September 14, 2020 11:01
@anaghavl
Copy link
Copy Markdown
Contributor Author

Hi @decidim/product I don't know if this change is usable when the form has errors in some language. How will it be rendered? I think that it will be very difficult for the user to note that there's a mandatory translation missing for example..

@anaghavl how does this PR solves this situation?

@tramuntanal missed this, will update the PR for the same.

@carolromero carolromero added the release: v0.23 Issues that need to be tackled for v0.23 label Sep 14, 2020
@anaghavl
Copy link
Copy Markdown
Contributor Author

@mrcasals can you take a look at the latest commit?

content_tag(:select, id: tabs_id, class: "language-change") do
locales.each_with_index.inject("".html_safe) do |string, (locale, index)|
title = I18n.with_locale(locale) { I18n.t("name", scope: "locale") }
title += " (error!)" if error?(name_with_locale(name, locale))
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.

If wee go with this solution, the (error!) part should be using the I18n system! 😄

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.

Something like

title = if error?(name_with_locale(name, locale))
  I18n.with_locale(locale) { I18n.t("name_with_error", scope: "locale") }
else
  I18n.with_locale(locale) { I18n.t("name", scope: "locale") } 
end

@anaghavl anaghavl requested a review from mrcasals September 15, 2020 08:38
@mrcasals
Copy link
Copy Markdown
Contributor

Looking good, @anaghavl! Can you add some screenshots with an error to showcase it?

@mrcasals
Copy link
Copy Markdown
Contributor

Ah, the screenshot is in the description. @tramuntanal can you check this out, please?

Copy link
Copy Markdown
Contributor

@ivan-mr ivan-mr left a comment

Choose a reason for hiding this comment

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

Everything seems ok. Thanks @anaghavl !

@ivan-mr ivan-mr merged commit 01887b0 into develop Sep 15, 2020
@ivan-mr ivan-mr deleted the adding_dropdown_option_to_locales branch September 15, 2020 14:17
mrcasals added a commit to codegram/decidim that referenced this pull request Sep 16, 2020
* adding dropdown option to locales list

* fixing linter error

* adding test cases

* fixing PerceivedComplexity and CyclomaticComplexity

* fixing js lint errors

* disable no-invalid-this error

* Simplify code

* Simplify code

* Adding error to identify locale with error

* moving error to I18n

Co-authored-by: Marc Riera Casals <mrc2407@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-review module: admin module: core release: v0.23 Issues that need to be tackled for v0.23

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants