unit cde_lang;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, VersionControl, SimplyJSON, cde_dir, cde_types;
{stdcalls}
function GetLanguage: String; STDCALL;
function GetLocalizedString (const AMessageID: String): String; OVERLOAD; STDCALL;
function GetLanguageInfo (const ALanguageName: String): TCDELanguageInfo; STDCALL;
{Language consts}
{$I cde_lang_const.inc}
implementation
function GetLanguage: String;
begin
Result:= JSReadString('/general/language', 'russian', GetCDEPath + 'configs\configs.json');
end;
function GetLocalizedString (const AMessageID: String): String;
begin
Result:= JSReadString(AMessageID, 'String_is_not_localized...', GetCDEPath + 'languages\' + GetLanguage + '.json');
end;
function GetLanguageInfo (const ALanguageName: String): TCDELanguageInfo;
const CDefStr: String = '<Undefined>';
      CDefVersion: String = '0.0.0.0';
var FileName: string;
begin
FileName:= GetCDEPath + 'languages\' + ALanguageName + '.json';
with Result do
 begin
 liName:= JSReadString('/languageinfo/name', CDefStr, FileName);
 liAuthor:= JSReadString('/languageinfo/author', CDefStr, FileName);
 liVersion:= StrToVersionInfo(JSReadString('/languageinfo/version', CDefVersion, FileName));
 liCDEVersion:= StrToVersionInfo(JSReadString('/languageinfo/cde_version', CDefVersion, FileName));
 end;
end;
end.
