-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert static views to use I18n translation #1983
Conversation
*app/views/devise/confirmations/new.html.erb -Remove hard-coded string and replace with call to I18n.t *config/locales/en.yml -Add resend_instructions translation key
*app/views/devise/registrations/edit.html.erb -Remove hard-coded strings and replace with calls to I18n.t *config/locales/en.yml -Add the following translation keys: edit_resource (tokenized) leave_blank need_current_password update unhappy cancel confirm back -Brackets for strings that included them were moved into the translation in case some languages do not use brackets or use different brackets.
*app/views/devise/registrations/new.html.erb -Remove hard-coded "Sign up" string *config/locales/en.yml -Add sign_up translation key *test/helpers/devise_helper_test.rb -Change hard coded 'Sign up' string in I18n tests to use I18n.t to retrieve the translation. -Add translation for "Sign up" string to fr locale translations used internally for tests so view changes do not break existing tests.
*test/helpers/devise_helper_test.rb -Both the full path "lazy lookup" translation and the short key must be defined in order for the test to pass.
*app/views/devise/sessions/new.html.erb -Remove hard-coded "Sign in" string *config/locales/en.yml -Add sign_in translation key
*app/views/devise/passwords/edit.html.erb -Remove hard-coded strings and replace with calls to I18n.t -Change header and submit button to "Change password" to keep consistent with other views and avoid an extra translation *config/locales/en.yml -Add the following translation keys: change_password new_password confirm_password *test/integration/recoverable_test.rb -Update tests to use "Change password" for button name
*app/views/devise/passwords/new.html.erb -Remove hard-coded strings and replace with calls to I18n.t *config/locales/en.yml -Add the following translation keys: forgot_password send_instructions
*app/views/devise/unlocks/new.html.erb -Remove hard-coded strings and replace with calls to I18n.t *config/locales/en.yml -Add the following translation keys: resend_instructions
*app/views/devise/shared/_links.erb -Remove hard-coded strings and replace with calls to I18n.t -Most translation keys are from other controllers / actions since the strings already existed in the targets of the links *config/locales/en.yml -Add the following translation keys: no_instructions omni_sign_in -The no_instructions key is common between the confirmation instructions link and the unlock instructions link and accepts an 'operation' parameter and is found in the root devise key path. -The omni_sign_in key is in a new key path called omniauth since it is not callback-related.
Thank you so much for the pull request. Yes this seems useful, but we think that this is an unnecessary complexity for those not using i18n. See #1642. |
I'm not sure I understand why having the views use I18n is unnecessarily complex but having the controllers use I18n is not. Speaking only for myself, it was a frustrating surprise when I discovered that the views were not internationalized since that meant I would have to write the additional translations myself instead of being able to rely on the existing community translations. I only speak English so I had to impose on my fiancée to help me complete the translation of the views into the other target language for my application. I think having the Devise community available to help with the translation is a compelling reason to use I18n in the views as well. |
There are project to do this (add more i18n support to Devise). I'm not maintainer of this project yet, (despite having the right and liberty to commit, merge, close and discuss pull requests), I'm not familiar with the source code and with the decisions, but in my opinion this should not be part of devise core. There are a lot of project doing this right now and my suggestion is: improve these project. For example, these two projects (https://github.com/tigrish/devise-i18n and https://github.com/sgruhier/devise_simple_form_views_generator) can be merged and improved to do exactly what you proposed. In this way the community can help with the translation without the need of us (from @plataformatec) to review every pull request. I think this is the best move to everyone. WDYT? I can help with the maintenance of these projects, we only need to coordinate with the original authors. |
Thanks @rafaelfranca . As I said in #1642: In our experience, if your app is used in just one language (which is the majority), it is easier to copy the views to your application and translate it (rails g devise:views) than fiddling with a yaml file. This is our preference. If you want to re-use views in a multi-language app, there is already a gem that does it. If your app is in one language, it is much, much, much easier to copy the views and translate directly in the view. It is much better to look at the real text in your views if you can, instead of |
I needed to convert the built-in devise views to use I18n for a personal project and thought this might be useful for others since I had to do the work anyway.
All strings have been added to config/locales/en.yml.