Skip to content

Commit

Permalink
utranslations, find lcl baselang
Browse files Browse the repository at this point in the history
  • Loading branch information
riderkick committed Jun 12, 2015
1 parent 1230f83 commit 7cc0bb6
Showing 1 changed file with 43 additions and 29 deletions.
72 changes: 43 additions & 29 deletions baseunits/utranslation.pas
Original file line number Diff line number Diff line change
Expand Up @@ -832,46 +832,60 @@ function GetLangName(lcode: string; useNativeName: Boolean): string;

function TranslateLCL(Lang: string): Boolean;
var
lcllangdir, lcllangpath, s: string;
lcllang, lcllangdir, lcllangpath: string;
mofile: Boolean;
i: Integer;
begin
Result := False;
lcllangpath := '';
mofile := False;
if LangDir <> '' then
begin
lcllangdir := LangDir;
if RightStr(lcllangdir, 1) <> PathDelim then
lcllangdir := lcllangdir + PathDelim;
s := lcllangdir + 'lclstrconsts.' + Lang;
if FileExistsUTF8(s + '.po') then
lcllangpath := s + '.po'
else if FileExistsUTF8(s + '.mo') then
begin
lcllangpath := s + '.mo';
mofile := True;
end;
end;

if lcllangpath = '' then
procedure FindLCLFile;
var
i: Integer;
s: string;
begin
for i := Low(ldir) to High(ldir) do
if LangDir <> '' then
begin
lcllangdir := GetCurrentDirUTF8 + PathDelim + ldir[i];
s := lcllangdir + 'lclstrconsts.' + Lang;
lcllangdir := LangDir;
if RightStr(lcllangdir, 1) <> PathDelim then
lcllangdir := lcllangdir + PathDelim;
s := lcllangdir + 'lclstrconsts.' + lcllang;
if FileExistsUTF8(s + '.po') then
begin
lcllangpath := s + '.po';
Break;
end
lcllangpath := s + '.po'
else if FileExistsUTF8(s + '.mo') then
begin
lcllangpath := s + '.mo';
mofile := True;
Break;
end;
end;
if lcllangpath = '' then
begin
for i := Low(ldir) to High(ldir) do
begin
lcllangdir := GetCurrentDirUTF8 + PathDelim + ldir[i];
s := lcllangdir + 'lclstrconsts.' + lcllang;
if FileExistsUTF8(s + '.po') then
begin
lcllangpath := s + '.po';
Break;
end
else if FileExistsUTF8(s + '.mo') then
begin
lcllangpath := s + '.mo';
mofile := True;
Break;
end;
end;
end;
end;

begin
Result := False;
lcllangpath := '';
mofile := False;
lcllang := Lang;
FindLCLFile;
if lcllangpath = '' then
begin
if Pos('_', lcllang) <> 0 then
SetLength(lcllang, Pos('_', lcllang)-1);
FindLCLFile;
end;
if lcllangpath <> '' then
begin
Expand Down

0 comments on commit 7cc0bb6

Please sign in to comment.