Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to Use Localized Help in English Visual Studio 2012 & 2013 & 2015

0.00/5 (No votes)
7 Aug 2016 1  
English Visual Studio and localized Help.

Introduction

This article contains a lot of C# code and instructions for using translated Help on pressing F1 in Visual Studio IDE text editor.

Background

Some developers in my team switch to C# from other languages. But its skill in English is not enough for fast reading and understanding a new language with new technology. Ok. You can say: install VS with Russian or German and use it. But there is a difficulty. One man who can help them with IDE is me, but I used VS a long long time ago only in English and at this point I can't help my friends with its questions.

I spent some time and investigated how VS call help by F1. If you skip some detail IDE run HlpViewer.exe with command line. AHA, I say.

Preliminary Steps

  1. Install English VS 2015 (10-12-13)
  2. Run Add and remove Help content (Ctrl+Alt+F1) and install documentation in English
  3. Change VS language to Russian (German or other) (https://www.microsoft.com/en-US/download/details.aspx?id=48157)
  4. Run Add and remove Help content (Ctrl+Alt+F1) and install documentation in Russian (German or other)
  5. Load binaires or source files
  6. Rename 'C:\Program Files (x86)\Microsoft Help Viewer\v2.2\HlpViewer.exe' to HlpViewer2.exe (or other name)
  7. Copy binaries to 'C:\Program Files (x86)\Microsoft Help Viewer\v2.2' folder

Code

The code is trivial for C# and there is no need for any comments.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.ComponentModel;
using System.Windows.Forms ;

namespace VSHelpViewer
{
  class Program
  {
    static NLog.Logger m_logger = NLog.LogManager.GetCurrentClassLogger();
    static void Main(string[] args)
    {
      LogSettings(args);

      Process proc = new Process();
      proc.StartInfo.UseShellExecute = false;
      proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      proc.StartInfo.CreateNoWindow = true;
      proc.StartInfo.FileName = Properties.Settings.Default.RenamedHlpViewer;
      List<string> arguments = new List<string>();
      foreach (string s in args)
      {

        if (s == Properties.Settings.Default.OriginalLocale)
        {
          arguments.Add(Properties.Settings.Default.TargetLocale);
        }
        else
        {
          arguments.Add(s);
        }
      }

      proc.StartInfo.Arguments = String.Join(" ", arguments);
      m_logger.Info("Dispatching with " + proc.StartInfo.Arguments);
      proc.Start();
      proc.Dispose();
      m_logger.Info("Exit");
    }
    private static void LogSettings(string[] args)
    {
      m_logger.Info("Starting with " + string.Join(" ", args));
      m_logger.Info("Settings:");
      m_logger.Info("OriginalLocale:" + Properties.Settings.Default.OriginalLocale);
      m_logger.Info("TargetLocale:" + Properties.Settings.Default.TargetLocale);
      m_logger.Info("RenamedHlpViewer:" + Properties.Settings.Default.RenamedHlpViewer);
    }
  }
}  

Using the Source

Compile to Debug or Release.

Rename original 'HlpViewer.exe' to 'HlpViewer2.exe' and copy of project 'HlpViewer.exe', 'HlpViewer.exe.config', 'NLog.config', 'NLog.dll' in 'C:\Program Files (x86)\Microsoft Help Viewer\v2.0" for MS VS 2012 or 'C:\Program Files (x86)\Microsoft Help Viewer\v2.1' for MS VS 2013 or 'C:\Program Files (x86)\Microsoft Help Viewer\v2.2' for MS VS 2015 directory.

Edit config for change settings:

 <userSettings>
    <VSHelpViewer.Properties.Settings>
        <setting name="TargetLocale" serializeAs="String">
            <value>ru-RU</value>
        </setting>
        <setting name="RenamedHlpViewer" serializeAs="String">
            <value>HlpViewer2.exe</value>
        </setting>
        <setting name="HlpViewerFolder" serializeAs="String">
            <value>C:\Program Files (x86)\Microsoft Help Viewer\v2.2</value>
        </setting>
        <setting name="OriginalLocale" serializeAs="String">
            <value>en-US</value>
        </setting>
    </VSHelpViewer.Properties.Settings>
</userSettings>

That's all!

Now when you press F1 on line with code you get localized Help. If you ask help which has no translation of your language, try to set checked "English content in all navigation tabs and F1 requests" check box and you get English help or set 'TargetLocale' property in the necessary language.

History

  • 1.0 Init version article
  • 1.1 Change code, add source project and binaries for VS 2015

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here