4

We have the application in delphi and now we are implementing language translation feature. We added the code in core to translate the strings which are declared in ResourceString. It is working fine but strings which is declared in Array not translated. Example

resourcestring
 Error_Text = 'Invalid Value'; 

This is Working fine.

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

How do i add these array values into resourcestring?

1 Answer 1

6

I think you can't directly have an array of resourcestring. I'd try a function instead, something like:

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.