Browse Source

* Added some fileexists() near places where a stream was opened, but
relied on the exception mechanism to handle file not found.
Makes debugging easier.

git-svn-id: trunk@24274 -

marco 12 years ago
parent
commit
3cc61e6195
1 changed files with 28 additions and 19 deletions
  1. 28 19
      packages/fcl-base/src/gettext.pp

+ 28 - 19
packages/fcl-base/src/gettext.pp

@@ -331,30 +331,39 @@ procedure TranslateResourceStrings(const AFilename: String);
 var
 var
   mo: TMOFile;
   mo: TMOFile;
   lang, FallbackLang: String;
   lang, FallbackLang: String;
+  fn: String;
 begin
 begin
   GetLanguageIDs(Lang, FallbackLang);
   GetLanguageIDs(Lang, FallbackLang);
-  try
-    mo := TMOFile.Create(Format(AFilename, [FallbackLang]));
-    try
-      TranslateResourceStrings(mo);
-    finally
-      mo.Free;
-    end;
-  except
-    on e: Exception do;
-  end;
+  fn:=Format(AFilename, [FallbackLang]);
 
 
+  if fileexists(fn) then
+    begin
+      try
+        mo := TMOFile.Create(fn);
+        try
+          TranslateResourceStrings(mo);
+        finally
+          mo.Free;
+        end;
+      except
+        on e: Exception do;
+      end;
+    end;
   lang := Copy(lang, 1, 5);
   lang := Copy(lang, 1, 5);
-  try
-    mo := TMOFile.Create(Format(AFilename, [lang]));
-    try
-      TranslateResourceStrings(mo);
-    finally
-      mo.Free;
+  fn:=Format(AFilename, [lang]);
+  if fileexists(fn) then
+    begin
+      try
+        mo := TMOFile.Create(Format(AFilename, [lang]));
+        try
+          TranslateResourceStrings(mo);
+        finally
+          mo.Free;
+        end;
+      except
+        on e: Exception do;
+      end;
     end;
     end;
-  except
-    on e: Exception do;
-  end;
 end;
 end;