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()
delete[] native_str;
/* Linux and Unix */
#elif defined (__UNIX__)
#elif defined(__UNIX__)
// Under Linux, if argv[0] doesn't the complete path to the executable,
// it's necessary to obtain it using "which <filename>".
......@@ -454,6 +454,7 @@ bool WinEDA_App::SetBinDir()
return TRUE;
}
/**
* Set search paths for libraries, modules, internationalization files, etc.
*/
......@@ -527,9 +528,9 @@ void WinEDA_App::GetSettings()
/* Load the last file history settings from legacy version if this is the
* 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" );
if( ii != 0 )
......@@ -721,7 +722,6 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id )
}
void WinEDA_App::SetLanguagePath( void )
{
size_t i;
......@@ -734,6 +734,7 @@ void WinEDA_App::SetLanguagePath( void )
wxFileName fn( m_searchPaths[i], wxEmptyString );
fn.AppendDir( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended
* for all other platforms. */
fn.AppendDir( wxT( "kicad" ) );
......@@ -842,6 +843,10 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename,
* 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
* 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 )
{
......@@ -860,10 +865,29 @@ wxString WinEDA_App::GetHelpFile( void )
subdirs.Add( wxT( "kicad" ) );
#endif
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() );
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.Add( _T( "en" ) );
......@@ -873,12 +897,14 @@ wxString WinEDA_App::GetHelpFile( void )
return fn;
}
wxString WinEDA_App::GetLibraryFile( const wxString& filename )
{
wxArrayString subdirs;
subdirs.Add( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended for
* all other platforms. */
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