English 中文(简体)
j Query UI Slider and jQuery Globalization with Value delimited by comma [ ,]
原标题:jQuery UI Slider and jQuery Globalization with value delimited by comma [ , ]

I m 开发一个伙伴关系。 NET MVC 3 表示使用 and jQuery UI Slider

我将这一信息提供给来自巴西的葡萄牙人(即葡萄牙语),并支持英语。

问题是,当我把语言改为葡萄牙语时,所有模型<代码>float的数值都以7.7等 com(......)加以限定。 然后,我试图确定Slider的最初价值,但只接受价值7.7的斜线(......)。

克服这种局面

$.CreateSlider("#sliderHeight", "#Height", @Model.Height.FormatValue(), 0, 2.5, 0.01);

FormatValue is an extension method:

public static string FormatValue(this float value)
{
    return value.Value.ToString().Replace(",", ".");
}

你们看到,我不得不用直截了当的限定语取代 com,以便我能够确定 j的Slider值。

因此,我不得不利用“金色全球化”来展示国库的正确价值:

$(textBox).val($.global.format(ui.value,  n2 ));

它至少发挥作用......

我的问题是:

这样做是否有更好或标准的方法?

重要的是,《示范法》的价值观正在走到应有的道路上,也就是说,随着我把文化转向适应-BR,数字就会被划定(......、......)。 我认为这是正确的。 限制方式是获得价值。

仅补充一点:如果我试图通过这些数值从<条码>@Model中取出,那么我有这样的东西,这显然会打破(由于参数本身与mas相分离):

$.CreateSlider("#sliderHeight", "#Height", 7,7 , 0, 2.5, 0.01);
最佳回答

Your slider accepts InvariantCulture values, so you need to provide such. Just modify your method:

public static string ParseValue(this float value)
{
    return value.Value.ToString(CultureInfo.InvariantCulture);
}

BTW. ParseValue is not the best name here as no parsing going on. FormatValue would sound better.
BTW. Your original method won t work correctly for some cultures (might not be visible for small values but for greater than i.e. 100 bad things could happen). If you need a dot as floating point, always use InvariantCulture.

问题回答

暂无回答




相关问题
.net Satellite assembly?

How can i create satellite assemblies in .net 3.5? I have a nativetext.resx file in english and want to create assemblies for french and italian in different folders like it --> nativetext.resources....

Access system:string resource dictionary XAML in C#

How do I access the contents in a resource dictionary using C#? For example, here is my code in XAML: <system:String x:Key="NewGroup">New Group Name</system:String> And I want to access ...

Localization in Prism WPF App

I m looking for the best way to localize a Prism 2 WPF app that might have several modules ported to Silverlight 3. Has anyone successfully localized a Prism 2 WPF app with several modules?

page content in multiple languages

I want to display content in more than one languages in a page. For example all menus are in English and content of post in local language (ie. Hindi). Contents on page are stored in database. For ...

Localization problem

I need to make a form that have to suport two languages (for now). the two languages dont have the same look and also half of the form is not a like but it still have some similiarity beetwen them. ...

determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

HOW TO MAKE localization?

I have a question about localization how can i do localization lets say that i have a dropdown list that holds the available languages: English,french and arabic and I have a label which get it says "...

热门标签