I'm trying to get this to work in a .Net 7 console application #43
-
I'm trying to get this to work in a .Net 7 console application but I am unclear how to create the service for this. Much appreciated. |
Beta Was this translation helpful? Give feedback.
Answered by
LazZiya
Jan 19, 2024
Replies: 2 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
1 reply
-
You need to switch to the target culture so 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);
} |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
LazZiya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to switch to the target culture so
XLocalizer
can read theCurrentCulture
param and localize to it accordingly.Just use below method for switching to a different culture: