@@ -231,21 +231,18 @@ orderby tool.Text
231231 var path = dir + @"\Documentation\" ;
232232 if ( Directory . Exists ( path ) )
233233 {
234- foreach ( string entry in Directory . GetFiles ( path ) )
234+ // Load English documents
235+ LoadDocuments ( docs , path ) ;
236+
237+ // Find any non-English documents by looking in \Documentation\<language code>\, e.g. \Documentation\es\
238+ foreach ( var codePath in Directory . GetDirectories ( path ) )
235239 {
236- // These are the following formats that can be selected.
237- if ( entry . Contains ( ".pdf" ) || entry . Contains ( ".doc" ) || entry . Contains ( ".docx" ) || entry . Contains ( ".pptx" ) || entry . Contains ( ".txt" ) )
238- {
239- var i = entry . LastIndexOf ( "\\ " ) ;
240- docs . Add ( new ToolStripMenuItem ( entry . Substring ( i + 1 ) , null , ( Object sender2 , EventArgs e2 ) =>
241- {
242- var docPath = ( sender2 as ToolStripItem ) . Tag as string ;
243- Process . Start ( docPath ) ;
244- } ) { Tag = entry } ) ;
245- }
246- contextMenuStripDocuments . Items . AddRange ( ( from tool in docs
247- orderby tool . Text
248- select tool ) . ToArray ( ) ) ;
240+ // Extract the last folder in the path - the language code, e.g. "es"
241+ var code = System . IO . Path . GetFileName ( codePath ) ;
242+
243+ // include any non-English documents that match the chosen language
244+ if ( code == Settings . Language )
245+ LoadDocuments ( docs , codePath , code ) ;
249246 }
250247 }
251248 else
@@ -264,6 +261,29 @@ orderby tool.Text
264261 }
265262 }
266263
264+ private void LoadDocuments ( List < ToolStripItem > docs , string folderPath , string code = null )
265+ {
266+ foreach ( var filePath in Directory . GetFiles ( folderPath ) )
267+ {
268+ var ext = System . IO . Path . GetExtension ( filePath ) ;
269+ var name = System . IO . Path . GetFileNameWithoutExtension ( filePath ) ;
270+ // These are the formats that can be selected.
271+ if ( new [ ] { ".pdf" , ".doc" , ".docx" , ".pptx" , ".txt" } . Contains ( ext . ToLowerInvariant ( ) ) )
272+ {
273+ var codeLabel = string . IsNullOrEmpty ( code ) ? "" : $ " [{ code } ]";
274+ docs . Add ( new ToolStripMenuItem ( $ "{ name } { ext } { codeLabel } ", null , ( object sender2 , EventArgs e2 ) =>
275+ {
276+ var docPath = ( sender2 as ToolStripItem ) . Tag as string ;
277+ Process . Start ( docPath ) ;
278+ } )
279+ { Tag = filePath } ) ;
280+ }
281+ contextMenuStripDocuments . Items . AddRange ( ( from tool in docs
282+ orderby tool . Text
283+ select tool ) . ToArray ( ) ) ;
284+ }
285+ }
286+
267287 void MainForm_FormClosing ( object sender , FormClosingEventArgs e )
268288 {
269289 SaveOptions ( ) ;
0 commit comments