added translation capability to body of mails sent for the instructions.
(error messages are pretty much translated although html views (hn or buttons) and mails body have not yet)
internationalized body of mailer--confirmation_instructions
internationalized body of mailer--reset_password_instructions
internationalized body of mailer--unlock_instructions
internationalized body of mailers
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 #1983 and #1642.
I actually guessed so, but did not notice, and just felt like "oh, some translations are missing".
How about adding more emphasized guidance from the master wiki toward the devise-i18n project?
For "those not using i18n", this part would be outside their head or interests, although for those using i18n, missing translations (OR missing "the existence of" translations) practically assigns them a lot of additional works.
Thank you so much for your pull request. As we're receiving a lot of pull requests about it recently, I think it is time, as you suggested, to emphasize guidance on this matter.
As you may have noticed, Devise views are only a way to quickly have a working authentication system, and as they are almost always overwritten with a custom view, adding it will only increase complexity on an environment that (at least initially) should be simple.
@orzccc feel free to update the wiki pages to provide the guidance you feel that it is missing. they are public and everyone has access to edit them! tks!
I've searched in devise-i18n issues also, i've found an issue dated 3 months ago for a future release of a devise-i18n-views gem, but googling for that i've only found a dismissed project on Github.
Internationalizing that views/mailers does not requires a giant amount of work and thus there are couple of attempts spread all over forums and groups.
So can I suggest that we could create a new gem right now, call it something like 'devise-intenationalized-views' and merge I18n views with @orzccc mailers.
Then if @josevalim, @rodrigoflores ... agree we could create/use a wiki page to provide guidance on how to actual translate views.
What about that?
This sounds perfect. Having a solid devise-i18n-views that we can recommend to others would be great. We could even add links to the README. Let us know when you get it done with!
@mcasimir if you look at #1983 I proposed this approach here. That said I'm 👍 for this path.
Ok done: https://github.com/mcasimir/devise-i18n-views
I've basically downloaded @orzccc version of mailers (with a fallback to English) and merged it with devise views translated in a crude way, such that the string "Sign In!" in file "views/devise/sessions/new.html.erb" is now <%= t("devise.sessions.new.sign_in", :default => "Sign In!") %>
It can be done better but it is a good starting point.
Maybe someone can help me to test it and discuss a little convention for I18n keys before publicly add it to the wiki. I don't know if this is the right place to talk about it, perhaps it would be better to move somewhere else, am I right? but where then?
I don't mind with continuing the discussion here. I would suggest to use the view shortcut for the translations though:
It is how it is commonly used in Rails apps and it is shorter. The only difference is that the key will now be devise.sessions.new.sign_in instead of devise.views.sessions.new.sign_in so you need to adjust the yml file accordingly. The reason the mailer uses devise.mailer as key is exactly because the name of the class is devise.mailer. :)
By default, Rails and I18n loads all translations in the config/locales/*. This means that, if you put all translations inside the gem, in the future you may have 20+ different translations and they will all be loaded into your app. This could possibly take MBs of memory. So I would suggest to put all translations into a translations directory at root and tell people to manually copy it to their apps.
Since you are already adding the default to the views, you don't need to have anything in config/locales and it should work fine.
About testing, the best recommendation I can give is to grab latest Rails and run:
rails plugin new --full devise-i18n-views
It will generate a full application inside test. In this application, you should install Devise, as you would for any app, and then you can test it as you would in any app. Simple assertions on the contents should do the trick.
Thanks for your suggestions, there is always something new to learn! Based on what you told me i've changed it as follows:
rails g devise_i18n_views:locale LOCALE
Nothing except basic translation is tested yet, tomorrow i could try to see what happens with the mailer but at this time i don't have so much time to write programmatic tests, i hope someone else could do that if it's necessary.
Also, i've never mantained a Gem before now, neither a small one, so i've no idea about how much time it takes, is it a busy task?
What about devise:views:locale LOCALE, could it be ok? I would prefer to mantain the generate something form, i found it easier to remember, but is not so important ;)
Ok renamed and tested the mailer also, now it seems ok to me.
updated mailer with plataformatec/devise#1989 (commits)