C
C#4mo ago
HiveMind

Change language at runtime in WPF

Hi! I have a set of *.resx files with translations and they work fine when I start the app. If I start on computer with english system, it chooses english translation, if I choose spanish system, it loads spanish translation, etc. But how can I change it at runtime? Currently, I'm doing it in this way:
C#
<Label FontSize="10" Foreground="Gray" Margin="0,10,0,0" Name="languageLabel" Content="{x:Static p:LanguageVersion.Settings_Language}"/>
C#
<Label FontSize="10" Foreground="Gray" Margin="0,10,0,0" Name="languageLabel" Content="{x:Static p:LanguageVersion.Settings_Language}"/>
And I guess, I will need to change every x:Static, but I'm ready for this sacrifice. I'm trying to change language in this manner:
C#
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("pl");
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("pl");
C#
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("pl");
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("pl");
But it doesn't do anything
3 Replies
sibber
sibber4mo ago
the culture isnt the app language its something thats used for things like in formatting like using , instead of . for numbers $dotnet
MODiX
MODiX4mo ago
.NET is a marketing term referring to a family of products, consisting of two different lineages. The .NET Framework ("netfx") lineage was introduced in 2002. This lineage runs only on Windows. Its most recent release is .NET Framework 4.8.1. While this lineage is still supported, very few new features are being introduced into it. Devs are encouraged not to target .NET Framework for new app development. The .NET Core ("netcore") lineage was introduced in 2016. This is a modern development platform which runs across many different OSes. The .NET Core 3.1 product was the last version in this lineage to bear the ".NET Core" name; and starting with the next release (.NET 5), the product was renamed to simply ".NET". .net6 in 2021, .net7 in 2022, .net8 in 2023 ... the next release in this lineage is .NET 9. This lineage is where new features are actively being developed. Devs are encouraged to target .NET for new app development. Nowadays, the ".NET" moniker usually refers to recent versions of the netcore lineage. When you create a new app targeting .NET (not .NET Framework!), you're targeting this newer, modern, cross-platform API surface and runtime.
sibber
sibber4mo ago
oops sorry wrong thread
Want results from more Discord servers?
Add your server