在安装过程中如何显示本地化的程序文件名称(显示名称)? [英] How to display localized Program Files name (display name) during installation?
问题描述
我当前正在创建一个安装程序,它的默认安装目录为 Program Files
.为此,我使用了 {pf}
.
I'm currently creating an installer, which has Program Files
as its default installation directory. To do this, I used {pf}
.
这是德语程序,仅在德国使用,并且在选择目标目录期间安装程序完全使用德语时,安装程序仍显示 C:\ Program Files
而不是本地化名称C:\ Programme
.
It's a German program and only used in Germany and while the installer is entirely in German during selection of the destination directory, setup still displays C:\Program Files
instead of the localized name C:\Programme
.
是否可以让它显示 C:\ Programme
?在功能上一切正常,该应用程序安装在 C:\ Programme
中.我只是担心基本用户可能会因为阅读 C:\ Program Files
而感到困惑.
Is it possible to get it to display C:\Programme
instead? Functionally everything works fine, the application is installed in C:\Programme
. I'm just concerned a basic user may be confused by reading C:\Program Files
.
更多信息:我知道 C:\ Programme
或 Program Files
的任何其他本地化名称只是一个显示名称,物理路径始终为程序文件
.不管哪个Windows版本或Windows使用哪种语言都没关系.但是我仍然希望安装程序在安装过程中显示 C:\ Programme
.
Further information: I know C:\Programme
or any other localized name for Program Files
is just a display name, the physical path is always Program Files
. Doesn't matter which Windows version or what language Windows has. Yet I'd still like setup to display C:\Programme
during installation.
我的测试计算机在Windows 7和Windows 10上.
My test machines are on Windows 7 and Windows 10.
推荐答案
Inno Setup不支持.
Inno Setup does not support that.
您将不得不伪造它.您可以根据需要动态地将 DirEdit
的内容转换为显示名称或从显示名称转换:
You would have to fake it. You can dynamically translate contents of the DirEdit
to/from a display name as needed:
- 激活选择目标位置"页面后,翻译为显示名称
- 单击浏览"按钮,转换为物理路径. 选择新路径后,
- 转换为显示名称.
- 单击下一步"按钮,转换为物理路径.
function ToDisplayName(Path: string): string;
begin
Result := ???;
end;
function FromDisplayName(Path: string): string;
begin
Result := ???;
end;
var
DirBrowseButtonClickOrig: TNotifyEvent;
OnSelectDir: Boolean;
procedure DirBrowseButtonClick(Sender: TObject);
begin
WizardForm.DirEdit.Text := FromDisplayName(WizardForm.DirEdit.Text);
DirBrowseButtonClickOrig(Sender);
WizardForm.DirEdit.Text := ToDisplayName(WizardForm.DirEdit.Text);
end;
procedure InitializeWizard();
begin
DirBrowseButtonClickOrig := WizardForm.DirBrowseButton.OnClick;
WizardForm.DirBrowseButton.OnClick := @DirBrowseButtonClick;
OnSelectDir := False;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
begin
OnSelectDir := True;
WizardForm.DirEdit.Text := ToDisplayName(WizardForm.DirEdit.Text);
end
else
begin
if OnSelectDir then
begin
OnSelectDir := False;
WizardForm.DirEdit.Text := FromDisplayName(WizardForm.DirEdit.Text);
end;
end;
end;
一个棘手的部分当然是 ToDisplayName
和 FromDisplayName
函数的实现.
A tricky part is of course the implementation of the ToDisplayName
and FromDisplayName
functions.
真正的本机实现会非常复杂,如果您可以使用Pascal脚本的有限功能(尤其是缺少指针)来实现它,甚至会产生疑问.
A real native implementation would be pretty complex and it's even questionable if you can implement it with limited features of the Pascal Script (particularly a lack of pointers).
但是对于您的特定需求,您可以使用一些简单的方法:
But for your specific needs, you can use something as trivial as:
[CustomMessages]
ProgramFilesLocalized=Programme
[Code]
function ToDisplayName(Path: string): string;
begin
StringChange(Path, '\Program Files', '\' + CustomMessage('ProgramFilesLocalized'));
Result := Path;
end;
function FromDisplayName(Path: string): string;
begin
StringChange(Path, '\' + CustomMessage('ProgramFilesLocalized'), '\Program Files');
Result := Path;
end;
如果您需要真正的实现来转换显示名称,请考虑问一个单独的问题.
If you need a real implementation for converting to/from display name, consider asking a separate question.
这篇关于在安装过程中如何显示本地化的程序文件名称(显示名称)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!