-
Notifications
You must be signed in to change notification settings - Fork 190
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
Error: Encountered an error generating the document: time data fév. 4, 2022
does not match format %b. %d, %Y
(french language)
#193
Comments
fév. 4, 2022
does not match format %b. %d, %Y
fév. 4, 2022
does not match format %b. %d, %Y
(french language)
Hey @cygsecc, thanks for letting me know about this. I thought setting the locale for the server affected all child Python processes. If you have updated Ghostwriter's server settings to use Python defaults to English, so you can reproduce the error like this:
It works if you set the locale for the process:
I'll look into this. The reporting engine should be able to pull in the locale set for Django and use it, but I'll need to experiment to make sure that's reliable. |
Small update because I had a little time to play with this: It looks like this is slightly more difficult to resolve with Django. With I wish it was a simple code update, but it might take a little more work than that. I keep seeing Babel is easy to use, so it might not take me too long to investigate it and see about using it. |
@cygsecc I have a potential workaround for you. I ran into this today when date formatting started outputting the month as March instead of Mar for
You can change the And here: https://docs.djangoproject.com/en/4.0/ref/templates/builtins/#std:templatefilter-date Save the file and restart Ghostwriter. I think this will work because Associated Press style is very similar to I have not done expensive testing but was able to confirm this config workaround with a test case. Theoretically, we want L1ON enabled for easy localization, but it's only used within HTML templates. In most cases where Ghostwriter displays a date, we have to enforce a specific date format ( |
Hello, thank you so much for the extensive response, it's really appreciated. Will definitely try as soon as possible. I saw on the Slack channel that you were planning to update the roadmap, can't wait to read it. I hope that localization will be high on the roadmap but I would understand if it's not top priority. |
@cygsecc No problem. I merged the changes described above and updated the documentation with notes: https://www.ghostwriter.wiki/getting-started/installation#notes-on-date_format Improving localization is a priority. I'll be looking into ways to more easily localize things. Disabling To be fair, I don't think I've been using I'm going to close this for now, but please re-open it if disabling |
Thank you for the fix @chrismaddalena. Unfortunately, I am unable to get it working.
I have restarted the container, just to be sure, but when I try to re-generate my report I still get the following error:
What am I doing wrong? |
As @er4z0r I also had the time to try it and it does not work either.
Error :
(I also restarted the containers |
@er4z0r @cygsecc Thanks for checking back in with your results. I'll detail it below, but I think there are two things you need to do:
If this is a production environment, you will need to re-run the There is also Django's translation of date format strings to consider. I documented them on the wiki to help with this, but it's still troublesome. Django uses its own format strings, some of which repurpose Python's. This can make translation difficult. https://www.ghostwriter.wiki/getting-started/installation#notes-on-date_format For example, I assume Django has In your report template, if you want an abbreviated month that is lowercase use the
I'm going to experiment with |
I looked into it and found a better way to support handling dates within the report templates. Here is the CHANGELOG you'll see soon:
I'll be updating the documentation once it's merged, but the gist is you won't have to provide a Python Old filter: New filter: The filter now uses The It will also be easier to chain those filters, like so: Unfortunately, this means report templates will have to be updated. The old filters are effectively deprecated. It's very much for the best, but I don't want to just invalidate templates. Not everyone will pay attention to the CHANGELOG file. I need to figure out a good way to handle this in the template linter to warn people. @er4z0r @cygsecc I appreciate your patience and help with this. The above solution should work for you, but the change should make it much easier. It also supports |
Hello,
I have finished creating my templates two weeks ago and they were working perfectly. But ever since we hit February, I'm getting the error
Encountered an error generating the document: time data 'fév. 7, 2022' does not match format '%b. %d, %Y'
I think I understand the bug but I don't know how I can resolve it. The language of the server is french and I think Jinja is expecting 'feb' and not 'fév' in
{{ report_date | format_datetime("%b. %d, %Y", "%d/%m/%y") }}
. This would explain why it worked during the making of the template in January (January is Janvier in french so%b
was equaljan
anyway). I already searched the web but I can't find anything related to it.What do you think ?
Thomas
The text was updated successfully, but these errors were encountered: