Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Look for documentation in Linux version
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 29 Apr 2018 19:21:15 +0000 (20:21 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 29 Apr 2018 19:21:15 +0000 (20:21 +0100)
source/frmMain.cpp

index 228c7a6..bfef196 100644 (file)
@@ -16,6 +16,7 @@
 // You should have received a copy of the GNU General Public License along
 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
 
+#include <cstdlib>
 #include <iostream>
 #include <algorithm>
 #include <vector>
@@ -3121,43 +3122,68 @@ void frmMain::ShowHelp( wxCommandEvent& event ){
     
        // Based on the operating system, work out where 
        // the documentation should be.
-    
-//#ifdef __APPLE__
+       
     
 #if defined(__HAIKU__)
-    
-#elif defined(__WIN32__)
-    
-    
+
+#elif defined(__WIN32__)    
     
 #else
     
-       if (wxFileExists("/usr/share/doc/xestiaab/index.html")){
-        
-               wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html"));
+       // Get the LANG environment variable
+       
+       char *languageEnvironmentVariableChar = getenv("LANG");
+       std::string languageEnvironmentVariable(languageEnvironmentVariableChar);
+       std::cout << wxString(languageEnvironmentVariable).BeforeFirst('.', nullptr).ToStdString() << std::endl;
+       
+       int executeResult = 0;
+       
+       wxString documentPath = wxString::Format("/usr/local/share/doc/xestiaab/%s.fodt", 
+               wxString(languageEnvironmentVariable).BeforeFirst('.', nullptr));
+       std::string commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString();
+       
+       if (wxFileExists(documentPath))
+               executeResult = system(commandToExecute.c_str());
+       
+       if (executeResult == 0)
                return;
         
 #if XSDAB_RELEASE == 0
+       documentPath = wxString::Format("/usr/share/doc/xestiaab/%s.fodt", 
+               wxString(languageEnvironmentVariable).BeforeFirst('.', nullptr));       
+       commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString();
+       
+       if (wxFileExists(documentPath))
+               executeResult = system(commandToExecute.c_str());
         
-       } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){
-        
-               wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html"));
+       if (executeResult == 0)
                return;
-        
 #endif 
-        
+    
+       // Attempt to launch using the "default" language.
+       
+       if (wxFileExists("/usr/share/doc/xestiaab/en_GB.fodt") && executeResult > 0)
+       {
+               commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString();
+               executeResult = system(commandToExecute.c_str());
+       }
+       else if (wxFileExists("/usr/local/share/doc/xestiaab/en_GB.fodt") && executeResult > 0)
+       {
+               commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString();
+               executeResult = system(commandToExecute.c_str());
        }
     
-#endif
+       if (executeResult == 0)
+               return;   
     
+#endif
+
 #if XSDAB_RELEASE == 0
-    
        wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!"));
-    
+       return;
 #else
-    
-       wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit http://documentation.xestia.co.uk/xestiaab/ for documentation"), _("Help documentation missing!"));
-    
+       wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit https://xestia.co.uk/addressbook for documentation"), _("Help documentation missing!"));
+       return;
 #endif
     
 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy