Skip to content

Using incorrect culture #1562

@gavinltomra

Description

@gavinltomra

/// <summary>
/// Gets the localiser for the specified culture
/// </summary>
/// <param name="culture">The culture to retrieve localiser for. If not specified, current thread's UI culture is used.</param>
public TLocaliser ResolveForCulture(CultureInfo? culture)
{
var cultureInfo = culture ?? CultureInfo.CurrentUICulture;
return FindLocaliser(cultureInfo)(cultureInfo);
}

This code is using the CurrentUICulture, which is not correct. It should be using the CurrentCulture instead. While these are often set to the same value, this is not always the case -- in particular, the UI culture is often en-US when the culture is some other English variant.

I noticed this error when calling ToOrdinalWords on a DateTime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions