【问题标题】:How to translate the string which is declared in Array in delphi?delphi 如何翻译数组中声明的字符串?
【发布时间】:2018-10-11 10:57:16
【问题描述】:

我们在 delphi 中有应用程序,现在我们正在实现语言翻译功能。我们在 core 中添加了代码来翻译 ResourceString 中声明的字符串。它工作正常,但未翻译在 Array 中声明的字符串。 示例

resourcestring
 Error_Text = 'Invalid Value'; 

这工作正常。

Const
 ERROR_TYPE : Array[0..2] of String = ('Invalid Name', 'Invalid Age', 'Invalid Address');

如何将这些数组值添加到资源字符串中?

【问题讨论】:

    标签: delphi delphi-xe2 pascal delphi-xe7


    【解决方案1】:

    我认为您不能直接拥有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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 2014-09-04
      • 1970-01-01
      相关资源
      最近更新 更多