-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Bound DateTimes Display in en-US Format Not Local Format #2049
Comments
I'm glad this is finally being looked at. It was logged on 8th of September 2017. It was originally reproduced by a Xamarin person the following day. This affects all Xamarin Forms users outside the USA, and Xamarin Forms users with non USA customers. |
just ringing the bell again on this issue, it's something that we're fighting with on a daily basis in a multi-lingual app. It's ready for work, and there are folks willing to help and submit PR's but we're still waiting for direction on how you'd like it solved. |
I'm seeing a similar problem when applying a StringFormat to an Entry - see my detailed description on the Xamarin.Forms forum here. It's not related to Cultures, but is related to how the Entry copes with formatting. I think my problem is subtly different to the one described in this issue - but related. Is it worth me adding a new issue, or add more details here? |
My 0.2$ is that there is in .NET already a functionality designed to handle formatting and parsing: CultureInfo.CurrentCulture If you from code format DateTime to a string with DateTime.Now.ToString() it will automatically use CultureInfo.CurrentCulture to format it. Same with parsing a string into a DateTime with DateTime.Parse - CurrentCulture is used. Right now it is a mess where on-screen keyboards uses device setting for region, but .NET code parsing/formatting strings are using display language/culture. In the case of English UI and Swedish region you are typing numbers with a "," (comma) as decimal separator, and .NET tries to parse it using "." (dot) as decimal separator. To tie up loose ends, Xamarin Forms should create a custom CultureInfo based on the settings on each platform/device (e.g. on iOS using Region settings), and assign as default to CultureInfo.CurrentCulture, so we, each and every developer, don't have to try and do it. As a WPF developer you were stumped when binding doesn't adhere to what I've described above (and I consider it a bug) but it is easy to solve for WPF with Don't get me started with UWP, in which they seem to have forgotten that people actually want to have region/formatting different from you display language (like a large portion of the world wants) . |
I just came across the same issue when binding an entry to a numeric property. It is even worse that the behaviour is different between types: CurrentCulture = de-de Binding from model to UI: ,i.e. only float properties are binded with the correct culture Binding from UI to model: As a first step, please at least unify the behaviour for all datatypes. |
How can a framework get to this point, v4.4, and still get decimals working only for en-US? |
Any news on this? |
Issue still reproducable in the latest Xamarin.Forms Version. |
Any info when this will be fixed? |
Binding a DateTime to a Label which expects a string should be a type error, unless the user explicitly provides a function. |
This issue surfaced when migrating from Xamarin.Forms 3.6.0.344457 to 4.4.0.991757. In our case, we have a custom Entry, where we replace comma with a dot, so that when the user clicks comma on the soft keyboard, it would get replaced by a dot. Weird solution, I know, but it used to work in 3.6.0.344457, but it doesn't in 4.4.0.99175. What has changed? Looking at the issue history, I can see some work was done in v3.6.0. It seems like it's a regression bug. |
This issue doesn't seem to have had any activity in a long time. We're working on prioritizing issues and resolving them as quickly as we can. To help us get through the list, we would appreciate an update from you to let us know if this is still affecting you on the latest version of Xamarin.Forms, since it's possible that we may have resolved this as part of another related or duplicate issue. If we don't see any new activity on this issue in the next 30 days, we'll evaluate whether this issue should be closed. Thank you! |
Yes it is still affecting the latest 4.8 version. |
Having a similar issue when converting between a list to a comma separated string in Xamarin.Forms 5.0.0.1874
I'm sure it can be worked around with converting it to a string when data is retrieved and then converting it back to a list on save, but that's not really the best use of time, and having to add hack properties is not great. |
Just an update https://developercommunity.visualstudio.com/t/xamarin-forms-entry-does-not-accept-foreign-langua/449922 is still an issue in forms v5.0.0.1931. I have a commercial app out where I need this to work. Two weeks ago I was told I needed multilingual support and this is the last thing holding me up. Has anyone found a workaround while this is in progress? |
I have a Xamarin app whose primary user base will not be in the United States and this will be a noticeable bug for us. There is no workaround for UWP that I can find. Any updates? |
@LeptronSoftware you can extend the control to actively replace the "." with a ",". |
@samhouts - This current SO post - DatePicker not showing year from current culture Thai may be related to this issue. |
try the following workaround: HTH |
Description
When you display a bound DateTime on a control like Label, it will always display the DateTime in en-US format. For users outside the USA this is a problem.
Original bug report:
https://bugzilla.xamarin.com/show_bug.cgi?id=58635
Notes about other platforms
On Silverlight, UWP, and WPF all controls inherit from FrameworkElement and FrameworkElement has the "Language" property. This is what drives DateTime formatting on these platforms. On Silverlight and WPF there is a bug where the Language property does not default to the local Language. So, by default WPF, and Silverlight have the same bug as Xamarin Forms. But, this can be solved with one line of code:
Here is a WPF sample app that shows this:
https://www.dropbox.com/s/2qcacomtsjweb1o/DateTimeWPF.7z?dl=0
But, on UWP, the Language property correctly defaults to the machine's local language. So, DateTime conversion shows up correctly in UWP by default.
So, Xamarin Forms probably needs a Language property, and this Language property needs to default from the machine's regional settings.
Steps to Reproduce
Expected Behavior
When a DateTime is converted to a string in binding, it should be converted with a vanilla ToString() which will use the machine's local language settings.
Actual Behavior
DateTimes are converted to USA format strings regardless of the regional settings.
Basic Information
Reproduction Link
https://MelbourneDeveloper@bitbucket.org/MelbourneDeveloper/xamarin-forms-scratch.git
The text was updated successfully, but these errors were encountered: