-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
translation issues #32
Comments
I'll try to explain. Current flask-babel implementation does not support localization domains - there's no way to tell flask-babel to look for translations outside of the global translation cache. I made a patch to flask-babel and submitted to @mitsuhiko, however he was busy and did not accept it at the time. I made corrections and patch still in pending state. So, right now, you have to use my customized version of the flask-babel to enable admin translations. Reason why it silently disables translations - not everyone wants to translate their application, so they might not have flask-babel installed. |
I've tryed the exemple given here (using Flask-BabelEx): https://github.com/mrjoes/flask-admin/blob/master/examples/babel/simple.py The only way I found to get the language I wanted was to modify :
into :
which is durty and not adaptable at all, as you can see. Furthermore, even with this modification, the dates were not properly shows (I was expecting 'day/month/year' format). Versions: |
Idea was that you open your administrative URL with ?lang=fr to switch to French and it will store it in the session. Sure, in real world application you might want to switch languages differently: have link which will store something in the session, or have special query string parameter for that, etc. As for dates - yes, DatePicker control that Flask-Admin is using is not localizable at all.. |
Ok, thanks for the precision, it works (I thought that the language of the user was supposed to be detected automatically). |
I have tried to a add a little menu to make language selection user-frendly, but I failed. Anyway I give you the code, so I hope it will give you some inspiration at least. I've added this code at the end of flask_admin/templates/admin/layout.html (may sounds stupid for you, but not for me, a complete newbie):
and this in flask_admin/templates/admin/base.html:
I'm sorry, I'm just discovering your code, javascript and website developpement. Maybe it would be better to make it with more python, but really it was to hard for me to figure out. Just a last thing; in trying to modify your code, I noticed that the files were encoded in ASCII. I don't know if it's your code, or github, or my OS, but the best practice seems to be to encode in UTF-8 without BOM, especially when it comes to write "русский" or "français" which, somehow somewhere, as to be in the code (once again, I don't know if you can make something for it, cause I'm just discovering Github as well). Sorry I can't help you more. |
Yes, template does not use gettext methods, as it was more of the example. You can wrap text with {{ _gettext('list') }} |
Sorry, I don't understand. In which file do I have to put it (I thought it would be in https://github.com/mrjoes/flask-admin/blob/master/flask_admin/templates/admin/model/list.html but it doesn't seems so)? |
If you're using custom layout from 'layout' sample, then I assume you also copied templates to your project. In this case, open copied 'list.html' file look for this line: <h2 id="brand">{{ admin_view.name|capitalize }} list</h2> Wrap 'list' with |
Ok I see, thanks. |
Flask-Admin==1.0.8, Flask-BabelEx==0.9.1 I find out "Already exits." in flask_admin/contrib/sqla/validators.py, lineno is 38, however, admin.po in translations/fr/LC_MESSAGES indicates that msgid "Aleardy exists." is related to |
flask-admin uses babel domains, which are not yet on the official flask-babel repo ( i think mrjoes sent a pull request 3 months ago)
as a result of that, flask-admin currently cannot be translated, unless you fork, or clone/use mr joes flask-babel fork or wait for flask-babel to pull mrjoes commits.
this dependency / issue isnt documented anywhere, and flask-admin does not complain about the them not being implemented, and instead defaults to the currently set strings.
tl;dr : why implement it that way, ( dependency on not yet pulled to official flask-babel repo ) ?
thanks.
The text was updated successfully, but these errors were encountered: