FileExistUTF8 problem lazarus / 68-Other OS ---------------------------------------------------------------------- BeanzMaster · 2018-06-28 21:29 Hi, i'm currently try to resolve a problem with the function FileExistUTF8. In my application i have : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Folder := '.' + PathDelim + FileDir + PathDelim;    //    LF := Folder + 'lclstrconsts' + '.' + Language + '.' + C_PoExtension;    if FileExistsUTF8(LF) then // existe-t-il ?      Translations.TranslateUnitResourceStrings('LCLStrConsts', LF,Language, UpperCase(Language)) // on traduit    else      ShowMessage('FileNotFound : '+LF);       Note LazUTF8 and LazFileUTils are in uses (not FileUtils) The FileExistsUTF8 always return me "file not found" My application work well on Linux Manjaro 64 bit and Windows 10 64 bit I'm on MacOS High Sierra and Lazarus 1.8.5 32 bit with carbon. What can i do ? Thanks Best regards ---------------------------------------------------------------------- taazz · 2018-06-28 22:13 use expandfilename to convert the relative path to absolute and see if that leads to the file you assume it points. ---------------------------------------------------------------------- BeanzMaster · 2018-06-29 13:00 Hi Expandfilename doing anything. I'm also tried by assigned folder value in hard like /Users/usename/Documents/Projets/Lazarus/Components/GIFViewer/demos/gi fview/languages/ I'm also tried FileExist(UTF8ToAnsi(LF); same issue. Do you think is related to MacOS High Sierra ? ---------------------------------------------------------------------- balazsszekely · 2018-06-29 13:41 @BeanzMaster I tested FileExist/FileExistsUTF8, both works fine on High Sierra. ---------------------------------------------------------------------- BeanzMaster · 2018-06-29 23:00 @GetMem It is the demo gifviewer is trandlated to english or french when you change language ? If yes, the problem gone from my MacOS or with ????? ---------------------------------------------------------------------- BeanzMaster · 2018-06-29 23:30 If i do Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ExtractFilePath(Application.ExeName) it return "/Users/usename/Documents/Projets/Lazarus/Components/GIFViewer/demos/g ifview.app/Contents/MacOS/" if i do Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i getCurrentDir it returns "/" So what's the trick under MacOS ? ---------------------------------------------------------------------- balazsszekely · 2018-06-30 09:02 QuoteIt is the demo gifviewer is trandlated to english or french when you change language ? I did not test with gifviewer, just with a regular file.  QuoteIf i do  ExtractFilePath(Application.ExeName) it returns: "/Users/usename/Documents/Projets/Lazarus/Components/GIFViewer/demos/g ifview.app/Contents/MacOS/" Yes because gifview.app(bundle) is basically a directory. When you're done with the development, you should copy the executable "gifview"(located in your main development folder) into the bundle("gifview.app/Contents/MacOS/") and replace the symlink with the executable. You can achieve this by right clicking gifview.app then "Show Package Contents". It's common practice(OSX) to keep the resources(images, language files, etc) inside the bundle, however if you wish a solution which will work on every major platform you can do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  PathToLangFiles: String;begin  {$IFDEF LCLcarbon}    PathToLangFiles := Copy(Application.ExeName, 1, Pos(ApplicationName + '.app', Application.ExeName) - 1) + PathDelim + 'languages';  {$ELSE}    PathToLangFiles := Application.ExeName + PathDelim + 'languages';  {$ENDIF}           end;       The above code will return the languages directory located in the main development folder, beside the executable(bundle on osx). ---------------------------------------------------------------------- BeanzMaster · 2018-06-30 13:08 Quote from: GetMem on June 30, 2018, 11:02:36 amQuoteIt is the demo gifviewer is trandlated to english or french when you change language ? I did not test with gifviewer, just with a regular file.  QuoteIf i do  ExtractFilePath(Application.ExeName) it returns: "/Users/usename/Documents/Projets/Lazarus/Components/GIFViewer/demos/g ifview.app/Contents/MacOS/" Yes because gifview.app(bundle) is basically a directory. When you're done with the development, you should copy the executable "gifview"(located in your main development folder) into the bundle("gifview.app/Contents/MacOS/") and replace the symlink with the executable. You can achieve this by right clicking gifview.app then "Show Package Contents". It's common practice(OSX) to keep the resources(images, language files, etc) inside the bundle, however if you wish a solution which will work on every major platform you can do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  PathToLangFiles: String;begin  {$IFDEF LCLcarbon}    PathToLangFiles := Copy(Application.ExeName, 1, Pos(ApplicationName + '.app', Application.ExeName) - 1) + PathDelim + 'languages';  {$ELSE}    PathToLangFiles := Application.ExeName + PathDelim + 'languages';  {$ENDIF}           end;       The above code will return the languages directory located in the main development folder, beside the executable(bundle on osx). Thanks GetMem. Yesterday i see, i enable the gdb output. This is because i've  enabled "Include Application Informations" in the project's option. I had also some problem with GDB and this project du to the symlinks  and by disable it all gone to the normal. I'll test your piece of code Thanks Cheers ---------------------------------------------------------------------- BeanzMaster · 2018-07-01 09:21 Thanks Getmem it solve the path problem, but ui is never translated ---------------------------------------------------------------------- balazsszekely · 2018-07-02 06:25 QuoteThanks Getmem it solve the path problem, but ui is never translated  You're welcome. Did you try to debug it? Unfortunately the debugger is not working properly on my OSX. ---------------------------------------------------------------------- BeanzMaster · 2018-07-03 22:40 Hi, Quote from: GetMem on July 02, 2018, 08:25:13 amYou're welcome. Did you try to debug it? Unfortunately the debugger is not working properly on my OSX. Me to, i have some problem with GDB on some application it work and sometime not GDB not stop and run continusly in background. Each time i want recompile lazarus ask me to stop DBG and i need to launch without debug. So i resolve my problem with path i'm use Application.Location for Win and Linux and Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Copy(Application.ExeName, 1, Pos(ApplicationName + '.app', Application.ExeName) - 1); for Mac Thanks again