-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Spring i18n needs TimeZone resolution as well as Locale resolution. [SPR-1528] #6227
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
Comments
Tom Czarniecki commented The above classes made it trivial to extend org.apache.velocity.tools.generic.DateTool to provide internationalised date handling. |
Nickolay Mazurkin commented I've implemented the timezone client definition as a full analogue of a locale engine in Spring. It works absolutely fine so I would be glad if such functionality became a standard in Spring Web (I've deleted all headers/package names in files - don't think it would be a problem for anyone) |
Xavier Dury commented
|
Nickolay Mazurkin commented I use my own DispatcherServlet subclass with a such method
|
Rossen Stoyanchev commented This issue has been resolved through a selective bulk update, as part of a larger effort to better manage unresolved issues. To qualify for the update, the issue was either created before Spring 3.0 or affects a version older than Spring 3.0 and is not a bug. There is a good chance the request was made obsolete, or at least partly outdated, by changes in later versions of Spring including deprecations. It is also possible it didn't get enough traction or we didn't have enough time to address it. One way or another, we didn't get to it. If you believe the issue, or some aspects of it, are still relevant and worth pursuing at present you may re-open this issue or create a new one with a more up-to-date description. We thank you for your contributions and encourage you to become familiar with the current process of managing Spring Framework JIRA issues that has been in use for over a year. |
Nick Williams commented A worthy suggestion was made here with example implementation and never adopted. I think this is a much-needed addition to Spring Framework 4.0. I am re-opening this, and will attempt to implement it and submit a pull request. |
Nick Williams commented I have submitted pull request 298 with thorough time zone support implement. I had no idea how big of a task this was going to be. Tom's attachments just began to scratch the surface as to what was needed to make this work. TimeZone support closely mirrors Locale support and appears to work very well. Thorough JavaDoc documentation and 69 unit tests back up the changes. I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement. |
Phil Webb commented Wow Nick, that is quite some work! Cheers. I have updated the pull request with a few comments, the main one is if we can use a Rossen Stoyanchev will probably also be interested in what you have done. Thanks for the great work, it really does look like a very complete solution. |
Nick Williams commented Thanks, Phil. I had a couple quick questions that I added to the pull request after you commented. I'll summarize them here. I'd appreciate some guidance so that I can take this to phase two.
Also: Do I really need to quash commits with my next commit? I know the dev guidelines said to do so, but I tried that on a different repo the other day and it did not go well. If that's a must, some instructions would sure be helpful. |
Phil Webb commented The
Recently, most core code has been developed using It might be worth waiting for Juergen Hoeller to review this before attempting that change, he might have different ideas here; but to answer the question: The No worries with that, it was more guidance. Certain JUnit features (such as We can easily squash commits during a merge, it is fine to leave them and in this case it may even help to show how the pull request evolved. |
Nick Williams commented Sounds good, Phil. I'll wait until Juergen Hoeller weighs in before I make any changes. Meanwhile, think you'll have a chance to look at my other pull request soon? It's much less extensive. :-) |
Nick Williams commented Phil, I really wanted to get this in Milestone 2, which is suppose to release this Monday. Could you poke Juergen and see if he's had a chance to look at this? I really want to commit the necessary changes so that it can be reviewed again and, hopefully, merged. |
Phil Webb commented I think the M2 date may slip by a week. Things are fairly hectic at the moment but I would like to see this make M2. |
Juergen Hoeller commented Indeed, 4.0 M2 has been postponed for at least a week - the deadline is July 15th now. The TimeZone stuff (a few related issues) is high up on my list there. Juergen |
Nick Williams commented Juergen and Phil, I haven't seen any movement on this 3 weeks. What can I do to make this happen? |
Nick Williams commented I'm starting to get concerned about my pull request's mergability. :-( |
Nick Williams commented According to JIRA, 4.0 M2 releases today. Phil Webb said he wanted to get this into Milestone 2, and I share that desire. If there are simple revisions that need to be made, I can turn that around in 2-3 hours this afternoon. If there are more major revisions that need to be made, it's going to take me several days. Juergen Hoeller, has this reached the top of your list yet? |
Nick Williams commented Juergen Hoeller, it has been almost four months since I submitted pull request 298. I really want to see this get merged into RC1. By this point, I'm concerned about whether it is even mergable anymore. There have been a lot of changes to master in the last four months. I haven't even received any guidance yet on what should be changed to make it acceptable (and I would need at least a week to make those changes). Can you review and provide some feedback, please? Thanks. |
Juergen Hoeller commented Nick, FYI, I'm trying a slightly different approach with a TimeZoneAwareLocaleResolver extending LocaleResolver. This feels quite straightforward and seems to lead to less impact overall, with the existing LocaleResolver strategies simply implementing the same strategy for TimeZone handing as well if they can (i.e. for cookies and session). Some mixing and matching is always possible in subclasses, or combining dynamic locale resolution with a fixed time zone (through setting setDefaultTimeZone - now on AbstractLocaleResolver). I've also added TimeZone access to LocaleContextHolder, backed by a TimeZoneAwareLocaleContext, with our JodaTimeContext and the JSR-310 DateTimeContext checking the TimeZone there if none has been set for Joda/JSR-310 specifically. I'm wrapping this up now and will commit it tonight. I hope you're ok with the combined LocaleResolver/LocaleContext approach: It's less spread out that way, with the existing points of configuration simply additionally dealing with a time zone. There's also less passing through, since it's all just based on existing LocaleResolver references now. Juergen |
Nick Williams commented That approach works fine with me. Sounds like it makes a lot of sense. So you won't need me to make revisions to my pull request? You're making them instead? |
Juergen Hoeller commented After a further iteration, I went with with a LocaleContextResolver (extends LocaleResolver) now, returning and accepting an org.springframework.context.i18n.LocaleContext. This allows for direct exposure to LocaleContextHolder there, and keeps the SPI flexible enough to accommodate further locale-related information in the future (through LocaleContext extensions). For the time being, we have (Simple)TimeZoneAwareLocaleContext and a corresponding getTimeZone() convenience accessor on LocaleContextHolder. Nick, the version committed now is conceptually based on your pull request but didn't actually pull it. It turned out to be easier to implement the revised approach in a fresh cut. There are a few further intentional differences beyond the LocaleResolver extension approach: e.g. there's no TimeZoneChangeInterceptor since I have yet to see somebody using an on-the-fly time zone switcher on every page in their website, based on a plain parameter convention. This is common for language switches but not for time zones, I feel. Instead, I've made it more convenient to programmatically change the locale and time zone in specific controllers, through new "changeLocale" methods on RequestContext. Alternatively, people may of course inject their LocaleResolver and call the setLocale(Context) methods directly. Let me know whether I've been missing something. There might be a few further tests that we could add, for example. Other than that, I'm pretty happy with the current cut - and grateful for your pull request which served as a great guideline! We hardly ever get pull requests of that extent, that's for sure. Juergen |
Nick Williams commented Sorry about the delay in responding. I've been pretty busy lately. First, I'd like to say thanks for making this happen. I am thrilled that Spring Framework 4 will finally have time zone support, and I'm glad I could be part of making it happen. For the most part, your commit looks good. I did have a few comments though:
Thanks, Nick |
Juergen Hoeller commented Nick, those are both good points. I'm about to sort them out tonight, so they'll certainly make 4.0 RC2. As for the author tags, for what it's worth, I simply kept them on the files that started as a copy of yours for me locally. It is indeed appropriate to add a few further attributions to files that were clearly influenced by your pull request as well... Juergen |
Juergen Hoeller commented I've refined LocaleContextHolder's setLocale accordingly now and introduced setTimeZone methods. I've also fixed the toString methods in Simple(TimeZoneAware)LocaleContext to never lead to an NPE. And I've added a few author tags :-) Juergen |
Nick Williams commented Excellent! Looks great, now! Thanks again, Juergen Hoeller! |
Uh oh!
There was an error while loading. Please reload this page.
Tom Czarniecki opened SPR-1528 and commented
Spring Web framework has really good and extensible support for Locale resolution. However, in many internationalised applications one also requires to be able to resolve TimeZones, so that a remote user can be shown, for example, transaction logs in their local TimeZone, and not in the TimeZone of the server. You can always retrieve the user's timezone from the database at login and store it using a known key in the session or look it up whenever you need it. What I propose is really a set of extensible interfaces and strategy classes, based on Spring's current locale resolution mechanism, to allow a uniform approach to TimeZone resolution. Guess I have done this too many times for clients :-)
Attachments:
Issue Links:
Referenced from: commits 44dee37, 7ed108e, 7b2ac6d, 4574528, c664010
5 votes, 7 watchers
The text was updated successfully, but these errors were encountered: