Skip to content

I'm trying to get this to work in a .Net 7 console application #43

Closed Answered by LazZiya
julianadormon asked this question in Q&A
Discussion options

You must be logged in to vote

You need to switch to the target culture so XLocalizer can read the CurrentCulture param and localize to it accordingly.

Just use below method for switching to a different culture:

using XLocalizer.Common;

...

using (CultureSwitcher cs = new("es"))
{
    var LocalizedString = Localizer["Hello world"];
    Console.WriteLine(LocalizedString);
}

using (CultureSwitcher cs = new("en-GB"))
{
    var LocalizedString = Localizer["Hello world"];
    Console.WriteLine(LocalizedString);
}

using (CultureSwitcher cs = new("en-US"))
{
    var LocalizedString = Localizer["Hello world"];
    Console.WriteLine(LocalizedString);
}

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@julianadormon
Comment options

Comment options

You must be logged in to vote
5 replies
@julianadormon
Comment options

@LazZiya
Comment options

@julianadormon
Comment options

@LazZiya
Comment options

@julianadormon
Comment options

Answer selected by LazZiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants