Commit 89e5909f authored by charras's avatar charras
Browse files

Solved: problem when searching non english help files

parent c3918aad
Loading
Loading
Loading
Loading
+47 −21
Original line number Diff line number Diff line
@@ -454,6 +454,7 @@ bool WinEDA_App::SetBinDir()
    return TRUE;
}


/**
 * Set search paths for libraries, modules, internationalization files, etc.
 */
@@ -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" ) );