0

I am looking a way to setup the application App.Resources.Culture based on the user selected language during the installation of the application by using inno setup.

There is a possibility to set registry key when installing and reading this value on startup, or saving the selected language into a txt-file, but can't I somehow simply set the applications settings string value by the installer? Such as Properties.Settings.Default.CultureDefault

Developing WPF application with .NET 4.5.2

ajr
  • 874
  • 2
  • 13
  • 29
  • 1
    Possible duplicate of [Where are the Properties.Settings.Default stored?](http://stackoverflow.com/questions/982354/where-are-the-properties-settings-default-stored) – Martin Prikryl May 08 '17 at 12:14
  • Regarding your recent edit: We know that you want to do this using Inno Setup. But you basically have two separate questions: 1) Where are the Properties.Settings.Default stored? 2) How to change that stored defaults using Inno Setup - You cannot ask two separate questions in one post - If you know 1), make it clear in your question - Show us the exact file/storage you want to change and how exactly you want to change it. – Martin Prikryl May 08 '17 at 16:11
  • The way I see it, the location is essentially part of the how. Location itself is not answering how to do it by inno setup and therefore this is not a duplicate of linked question "where are the settings stored". – ajr May 09 '17 at 12:00
  • Well, that way your question is basically too broad for Stack Overflow. And you are going against yourself. The way the question is asked, you need someone with both Inno Setup and WPF domain knowledge to answer it. You will have troubles finding someone like that. While if you had asked separate WPF-only (which would be duplicate) and Inno Setup-only questions, you would have your answer by now already! Just my 2 cents. – Martin Prikryl May 09 '17 at 12:21
  • The title of my question is not limiting the answers to and only to WPF **properties.settings.default**. Question is, what is the recommended way to set application language with inno setup during installation. The main part of my question just describes the approaches I had in mind. – ajr May 09 '17 at 12:27
  • There's nothing like *"application language"* in Windows. Such concept does not exist in general. There's only a global system/user language in Windows. Every application (if it chooses not to follow the global system/user language) has to implement the configuration on its own. Using its own configuration file/storage. There's no generic support for that in Windows or any kind of standard. - While WPF *framework* has a *"generic application"* language setting => Your question is about WPF only. – Martin Prikryl May 09 '17 at 12:54

1 Answers1

1

If I understand the question correct !?

You can not set the WPF culture setting via inno setup

You don't need to set the registry or create a .txt file

You can simply pass params to the created menu/desktop program links created by ...

Inno Setup

[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: nl; MessagesFile: "compiler:Languages\Dutch.isl"
Name: de; MessagesFile: "compiler:Languages\German.isl"

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"; Parameters : "{code:GetMyCulture|{app}}" 

[Code]

function GetMyCulture(Param: String):String;
var
lang,Cult : String;
begin
 Result := '';
 lang := ExpandConstant('{language}');
 Cult := '"-Cult" ';
 if lang = 'de' then Result := Cult + '"de-DE"';
 if lang = 'en' then Result := Cult + '"en-EN"';
 if lang = 'nl' then Result := Cult + '"nl-NL"';
end;

result : "D:\ProgramFiles\My Program\MyProg.exe" "-Cult" "nl-NL"

you have to setup the [Code] section with valid culture pairs.

WPF OnStartup() pseudo code not tested for valid e.Args[1]

protected override void OnStartup(StartupEventArgs e)
{
  if(e.Args.Length > 1) {
     string cult    = "-Cult";
     string cultone = e.Args[0];
     string culttwo = e.Args[1];
     if (cult.Equals(cultone))  {
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culttwo); ;
        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culttwo); ;

        FrameworkElement.LanguageProperty.OverrideMetadata(
          typeof(FrameworkElement),
          new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
     }
  }
 base.OnStartup(e);

 }
}

default-cultureinfo-for-wpf

moskito-x
  • 11,832
  • 5
  • 47
  • 60
  • Passing the selected language by parameter is certainly an interesting and valid general solution. However, I am already using program parameters for another purpose and would like to keep parameters at bare minimum... – ajr May 09 '17 at 12:06