mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-29 19:17:41 +00:00
Start moving data from forms to models/controllers for onlineupdate and establish a shared data pattern for transitional refactoring. Also establish a TLocaleStrings class which has no global variable dependency.
46 lines
1.3 KiB
ObjectPascal
46 lines
1.3 KiB
ObjectPascal
unit Keyman.System.LocaleStrings;
|
|
|
|
interface
|
|
|
|
uses
|
|
keymanapi_TLB,
|
|
MessageIdentifierConsts;
|
|
|
|
type
|
|
TLocaleStrings = class
|
|
class function MsgFromId(kmcom: IKeyman; const msgid: TMessageIdentifier): string;
|
|
class function MsgFromStr(kmcom: IKeyman; const str: string): string;
|
|
class function MsgFromIdFormat(kmcom: IKeyman; const msgid: TMessageIdentifier; const args: array of const): string;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.SysUtils,
|
|
|
|
custinterfaces;
|
|
|
|
class function TLocaleStrings.MsgFromStr(kmcom: IKeyman; const str: string): string;
|
|
begin
|
|
if kmcom = nil
|
|
then Result := str
|
|
else Result := Trim((kmcom.Control as IKeymanCustomisationAccess).KeymanCustomisation.CustMessages.MessageFromID(str));
|
|
end;
|
|
|
|
class function TLocaleStrings.MsgFromId(kmcom: IKeyman; const msgid: TMessageIdentifier): string;
|
|
begin
|
|
if kmcom = nil
|
|
then Result := IntToStr(Ord(msgid))
|
|
else Result := Trim((kmcom.Control as IKeymanCustomisationAccess).KeymanCustomisation.CustMessages.MessageFromID(StringFromMsgId(msgid)));
|
|
end;
|
|
|
|
class function TLocaleStrings.MsgFromIdFormat(kmcom: IKeyman; const msgid: TMessageIdentifier; const args: array of const): string;
|
|
begin
|
|
try
|
|
Result := Format(MsgFromId(kmcom, msgid), args);
|
|
except
|
|
Result := MsgFromId(kmcom, msgid) + ' (error displaying message parameters)';
|
|
end;
|
|
end;
|
|
|
|
end.
|