Index: /trunk/Packages/CoolTranslator/UCoolTranslator.pas
===================================================================
--- /trunk/Packages/CoolTranslator/UCoolTranslator.pas	(revision 120)
+++ /trunk/Packages/CoolTranslator/UCoolTranslator.pas	(revision 121)
@@ -6,5 +6,5 @@
 
 uses
-  Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs,
+  Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8,
   Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType;
 
@@ -46,4 +46,5 @@
     procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo);
     function IsExcluded(Component: TPersistent; PropertyName: string): Boolean;
+    function GetLangFileDir: string;
   public
     ComponentExcludes: TComponentExcludesList;
@@ -150,5 +151,5 @@
   I: Integer;
   LocaleShort: string;
-  Dir: string;
+  SearchMask: string;
 begin
   FPOFiles.Clear;
@@ -158,13 +159,14 @@
     //ShowMessage(ExtractFileDir(Application.ExeName) +
     //  DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po');
-    Dir := FPOFilesFolder;
-    if Copy(Dir, 1, 1) <> DirectorySeparator then
-      Dir := ExtractFileDir(UTF8Encode(Application.ExeName)) +
-      DirectorySeparator + Dir;
-    FileList := FindAllFiles(Dir, '*.' + LocaleShort + '.po');
+    SearchMask := '*';
+    if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort;
+    SearchMask := SearchMask + '.po';
+    FileList := FindAllFiles(GetLangFileDir, SearchMask);
     for I := 0 to FileList.Count - 1 do begin
       FileName := FileList[I];
       //FileName := FindLocaleFileName('.po');
-      if FileExistsUTF8(FileName) then FPOFiles.Add(TPOFile.Create(FileName));
+      if FileExists(FileName) and (
+      ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or
+      (LocaleShort <> '')) then FPOFiles.Add(TPOFile.Create(FileName));
     end;
   finally
@@ -289,4 +291,12 @@
 end;
 
+function TCoolTranslator.GetLangFileDir: string;
+begin
+  Result := FPOFilesFolder;
+  if Copy(Result, 1, 1) <> DirectorySeparator then
+    Result := ExtractFileDir(UTF8Encode(Application.ExeName)) +
+      DirectorySeparator + Result;
+end;
+
 procedure TCoolTranslator.LanguageListToStrings(Strings: TStrings);
 var
@@ -321,4 +331,5 @@
   I: Integer;
 begin
+  Result := '';
   if Text <> '' then begin
     for I := 0 to FPoFiles.Count - 1 do begin
@@ -347,10 +358,12 @@
 var
   I: Integer;
-begin
+  LangDir: string;
+begin
+  LangDir := GetLangFileDir;
   TLanguage(Languages[0]).Available := True; // Automatic
 
   for I := 1 to Languages.Count - 1 do
   with TLanguage(Languages[I]) do begin
-    Available := FileExistsUTF8(POFilesFolder + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
+    Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
       '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
   end;
@@ -364,4 +377,5 @@
   Languages := TLanguageList.Create;
   POFilesFolder := 'Languages';
+  CheckLanguageFiles;
 
   // LCL
@@ -386,5 +400,5 @@
 begin
   // Win32 user may decide to override locale with LANG variable.
-  Lang := GetEnvironmentVariableUTF8('LANG');
+  Lang := GetEnvironmentVariable('LANG');
 
   // Use user selected language
@@ -394,7 +408,7 @@
   if Lang = '' then begin
     for i := 1 to Paramcount - 1 do
-      if (ParamStrUTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or
-        (ParamStrUTF8(i) = '--lang') then
-        Lang := ParamStrUTF8(i + 1);
+      if (ParamStr(i) = '--LANG') or (ParamStr(i) = '-l') or
+        (ParamStr(i) = '--lang') then
+        Lang := ParamStr(i + 1);
   end;
   if Lang = '' then
@@ -404,6 +418,4 @@
     Lang := FOnAutomaticLanguage(Lang);
   end;
-
-  if Lang = 'en' then Lang := ''; // English files are without en code
 
   Result := Lang;
@@ -427,5 +439,5 @@
     Exit;
 
-  Result := ChangeFileExt(ParamStrUTF8(0), LCExt);
+  Result := ChangeFileExt(ParamStr(0), LCExt);
   if FileExistsUTF8(Result) then
     Exit;
