Languages - NKS0045

Use CultureManager.CurrentCultStr

This analyzer provides the following strings:

Context
String

Error List

Caller uses CultureInfo.CurrentUICulture.Name instead of CultureManager.CurrentCultStr

Suggestion Box

Use CultureManager.CurrentCultStr instead of CultureInfo.CurrentUICulture.Name

Description

CultureManager.CurrentCultStr gives you a current culture that is set by the kernel settings without affecting the host system.

Extended Description

This code analyzer detects the usage of CurrentUICulture from the CultureInfo class found in the System.Globalizaiton namespace.

The CultureInfo.CurrentUICulture.Name property gives you your current UI culture's name for your applications. However, Nitrocid is not a GUI application, so we've decided to make our own culture handler that respects your kernel settings.

It's advisable to use the CultureManager.CurrentCultStr property so that your mod can respect the kernel settings when it comes to cultures.

Analysis Comparison

To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:

Before the fix

Somewhere in your mod code...
public static void MyFunction()
{
    var culture = CultureInfo.CurrentUICulture.Name;
}

After the fix

Somewhere in your mod code...
public static void MyFunction()
{
    var culture = CultureManager.CurrentCultStr;
}

Suppression

You can suppress this suggestion by including it in the appropriate place, whichever is convenient.

For more information about how to suppress any warning issued by the Nitrocid analyzer, visit the below page:

Recommendation

We recommend that every caller which use this function use the recommended abovementioned method.

Last updated