1

我有一个使用 aspdotnetstorefront 构建的电子商务网站。语言环境设置为

de_DE

货币是瑞士法郎,它显示如下:

139,00 (CHF)

当收到收据通知时,我遇到了一个问题,价格如下所示:(错误的应该是139,00 (CHF)

1.390.000,00

货币的显示规范设置为:

#,###.00

我的 XML 包(受影响的行)如下所示:

<xsl:value-of select="receipt:FormatCurrencyWithoutCurrencyCode(Price)" disable-output-escaping="yes" />

FormatCurrencyWithoutCurrencyCode:

#region FormatCurrencyWithoutCurrencyCode
    /// <summary>
    /// Format the currency value into it's localized currency pattern
    /// </summary>
    /// <param name="sCurrencyValue">The currency value</param>
    /// <returns>The formatted currency string</returns>
    public virtual string FormatCurrencyWithoutCurrencyCode(string sCurrencyValue)
    {
        return FormatCurrencyWithoutCurrencyCode(sCurrencyValue, ThisCustomer.CurrencySetting);
    }

    /// <summary>
    /// Format the currency value into it's localized currency pattern
    /// </summary>
    /// <param name="sCurrencyValue">The currency value</param>
    /// <param name="sTargetCurrency">The target currency to base on</param>
    /// <returns>The formatted currency string</returns>
    public virtual string FormatCurrencyWithoutCurrencyCode(string sCurrencyValue, string sTargetCurrency)
    {
        InputValidator iv = new InputValidator("FormatCurrencyWithoutCurrencyCode");
        decimal value = iv.ValidateDecimal("CurrencyValue", sCurrencyValue);
        string targetCurrency = iv.ValidateString("TargetCurrency", sTargetCurrency);

        decimal amt = Currency.Convert(value, Localization.GetPrimaryCurrency(), targetCurrency);

        String tmpS = String.Empty;
        // get currency specs for display control:
        String DisplaySpec = Currency.GetDisplaySpec(targetCurrency);
        String DisplayLocaleFormat = Currency.GetDisplayLocaleFormat(targetCurrency);

        if (DisplaySpec.Length != 0 && Currency.NumPublishedCurrencies() > 1)
        {
            tmpS = amt.ToString(DisplaySpec);
        }
        else if (DisplayLocaleFormat.Length != 0)
        {
            CultureInfo formatter = new CultureInfo(DisplayLocaleFormat);

            // for debugging purposes
            if (CommonLogic.QueryStringUSInt("dec") > 0)
            {
                int decimalPlaces = CommonLogic.QueryStringUSInt("dec");
                formatter.NumberFormat.CurrencyDecimalDigits = decimalPlaces;
            }

            tmpS = amt.ToString("C", formatter);
            if (tmpS.StartsWith("("))
            {
                tmpS = "-" + tmpS.Replace("(", "").Replace(")", "");
            }
        }
        else
        {
            tmpS = Localization.CurrencyStringForDisplayWithoutExchangeRate(amt, false); // use some generic default!
        }

        return tmpS;
    }

    #endregion
4

0 回答 0