Commit 89e5909f authored by charras's avatar charras

Solved: problem when searching non english help files

parent c3918aad
...@@ -406,7 +406,7 @@ bool WinEDA_App::SetBinDir() ...@@ -406,7 +406,7 @@ bool WinEDA_App::SetBinDir()
delete[] native_str; delete[] native_str;
/* Linux and Unix */ /* Linux and Unix */
#elif defined (__UNIX__) #elif defined(__UNIX__)
// Under Linux, if argv[0] doesn't the complete path to the executable, // Under Linux, if argv[0] doesn't the complete path to the executable,
// it's necessary to obtain it using "which <filename>". // it's necessary to obtain it using "which <filename>".
...@@ -454,6 +454,7 @@ bool WinEDA_App::SetBinDir() ...@@ -454,6 +454,7 @@ bool WinEDA_App::SetBinDir()
return TRUE; return TRUE;
} }
/** /**
* Set search paths for libraries, modules, internationalization files, etc. * Set search paths for libraries, modules, internationalization files, etc.
*/ */
...@@ -527,9 +528,9 @@ void WinEDA_App::GetSettings() ...@@ -527,9 +528,9 @@ void WinEDA_App::GetSettings()
/* Load the last file history settings from legacy version if this is the /* Load the last file history settings from legacy version if this is the
* first time wxFileHistory was used to manage the file history. */ * first time wxFileHistory was used to manage the file history. */
if( m_fileHistory.GetCount() == ( size_t )0 ) if( m_fileHistory.GetCount() == (size_t) 0 )
{ {
for( ii = 0; ii < ( unsigned )m_fileHistory.GetMaxFiles(); ii++ ) for( ii = 0; ii < (unsigned) m_fileHistory.GetMaxFiles(); ii++ )
{ {
entry = wxT( "LastProject" ); entry = wxT( "LastProject" );
if( ii != 0 ) if( ii != 0 )
...@@ -721,7 +722,6 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id ) ...@@ -721,7 +722,6 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id )
} }
void WinEDA_App::SetLanguagePath( void ) void WinEDA_App::SetLanguagePath( void )
{ {
size_t i; size_t i;
...@@ -734,6 +734,7 @@ void WinEDA_App::SetLanguagePath( void ) ...@@ -734,6 +734,7 @@ void WinEDA_App::SetLanguagePath( void )
wxFileName fn( m_searchPaths[i], wxEmptyString ); wxFileName fn( m_searchPaths[i], wxEmptyString );
fn.AppendDir( wxT( "share" ) ); fn.AppendDir( wxT( "share" ) );
#ifndef __WXMSW__ #ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended /* Up on level relative to binary path with "share/kicad" appended
* for all other platforms. */ * for all other platforms. */
fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "kicad" ) );
...@@ -842,6 +843,10 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename, ...@@ -842,6 +843,10 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename,
* for the current locale is not found, an attempt to find the English * for the current locale is not found, an attempt to find the English
* version of the help file is made. wxEmptyString is returned if the * version of the help file is made. wxEmptyString is returned if the
* help file is not found. * help file is not found.
* Help file is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/ */
wxString WinEDA_App::GetHelpFile( void ) wxString WinEDA_App::GetHelpFile( void )
{ {
...@@ -860,10 +865,29 @@ wxString WinEDA_App::GetHelpFile( void ) ...@@ -860,10 +865,29 @@ wxString WinEDA_App::GetHelpFile( void )
subdirs.Add( wxT( "kicad" ) ); subdirs.Add( wxT( "kicad" ) );
#endif #endif
subdirs.Add( _T( "help" ) ); subdirs.Add( _T( "help" ) );
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( m_Locale->GetCanonicalName() ); subdirs.Add( m_Locale->GetCanonicalName() );
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs ); fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
if( !fn && m_Locale->GetCanonicalName() != wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH )->CanonicalName ) // Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
subdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); // GetName( ) does not return always the short name
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{ {
subdirs.RemoveAt( subdirs.GetCount() - 1 ); subdirs.RemoveAt( subdirs.GetCount() - 1 );
subdirs.Add( _T( "en" ) ); subdirs.Add( _T( "en" ) );
...@@ -873,12 +897,14 @@ wxString WinEDA_App::GetHelpFile( void ) ...@@ -873,12 +897,14 @@ wxString WinEDA_App::GetHelpFile( void )
return fn; return fn;
} }
wxString WinEDA_App::GetLibraryFile( const wxString& filename ) wxString WinEDA_App::GetLibraryFile( const wxString& filename )
{ {
wxArrayString subdirs; wxArrayString subdirs;
subdirs.Add( wxT( "share" ) ); subdirs.Add( wxT( "share" ) );
#ifndef __WXMSW__ #ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended for /* Up on level relative to binary path with "share/kicad" appended for
* all other platforms. */ * all other platforms. */
subdirs.Add( wxT( "kicad" ) ); subdirs.Add( wxT( "kicad" ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment