开发者

Changing AppName and AppDir depending on language in Inno Setup

It's been a while since I was reading some questions/answers concerning InnoSetup, but none of them seems to help me... I want to change the AppName value depending on the language selected, being available English and Spanish. So, if the language chosen when prompted the dialog were Spanish, the AppName value should be "La Bola"; otherwise, if chosen English, the AppName value should be "The Ball".

The same thing applied to the AppDir. The only thing I've found so far was this Inno setup and DefaultDirName, but I cannot make it work with the Languages. Also tried using ISPP conditionals following an example:

#ifdef AppEnterprise
  #define AppName "My Program Enterprise Edition"
#else
  #define AppName "My Program"
#endif
开发者_C百科

but yet I cannot make it work with the Language, since I don't know how.

Is it possible to change it? =/

Greetings!


I had the same question, so I'm posting an answer that would allow others to get it faster.

Actually, there is an example in Examples\Languages.iss file in Inno Setup installation folder.

To be short:

[Setup]
AppName={cm:MyAppName}

then

[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"

then

[CustomMessages]
en.MyAppName=The Ball
es.MyAppName=La Bola

That's it. For more details, see the example. By the way, note that there is a LicenseFile language attribute available (this is not mentioned in the example):

[Languages]
Name: en; MessagesFile: "compiler:Default.isl"; LicenseFile: "eula_en.rtf"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"; LicenseFile: "eula_es.rtf"


Look at CustomMessages which can be translated into different languages, These can then be used in AppName and DefaultDirName with the {cm:..} constant.


ISPP is a Pre-Processor, so this means this code run's prior to compiling the SETUP.EXE

The AppName is used for a variety of purposes but one is the SETUP.EXE Resource. Which is why it can't be set at runtime using {code: }

So you could a compile time and have a different SETUP.EXE for each language.

You can do this in a number of ways, using the ISPP, here is one.

#define lang = "english"
[Setup]
#if lang == "english"
AppName=The Ball
#elif lang == "spanish"
AppName=La Bola
#else
# error Unsupported Language
#endif

AppVersion=1.5
;AppVerName=My Program 1.5
DefaultDirName={pf}\My Program

[Languages]
#if lang == "english"
Name: "en"; MessagesFile: "compiler:Default.isl"
#elif lang == "spanish"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
#else
# error Unsupported Language
#endif


[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜