Nij*_*esh 4 delphi pascal delphi-xe2 delphi-xe7
我们在delphi中有应用程序,现在我们正在实现语言翻译功能.我们在core中添加了代码来翻译在ResourceString中声明的字符串.它工作正常,但在Array中声明的字符串未翻译.例
resourcestring
Error_Text = 'Invalid Value';
Run Code Online (Sandbox Code Playgroud)
这工作正常.
Const
ERROR_TYPE : Array[0..2] of String = ('Invalid Name', 'Invalid Age', 'Invalid Address');
Run Code Online (Sandbox Code Playgroud)
如何将这些数组值添加到resourcestring中?
我想你不能直接拥有一个数组resourcestring.我会尝试一个函数,例如:
resourcestring
ERROR_TYPE0 = 'Invalid Name';
ERROR_TYPE1 = 'Invalid Age';
ERROR_TYPE2 = 'Invalid Address';
type
TMyIndexType = 0..2;
function ERROR_TYPE(AIndex: TMyIndexType): string;
begin
case AIndex of
0: Result := ERROR_TYPE0;
1: Result := ERROR_TYPE1;
2: Result := ERROR_TYPE2;
else
// appropriate error handling
end;
end;
Run Code Online (Sandbox Code Playgroud)