Community
    • Login

    Howto get Notapad++ GUI-language on C#?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    2 Posts 1 Posters 993 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mario RosenbohmM
      Mario Rosenbohm
      last edited by

      Hello,

      how can i detect the GUI-language from an C#-Plugin?

      regards
      Mario

      1 Reply Last reply Reply Quote 0
      • Mario RosenbohmM
        Mario Rosenbohm
        last edited by

        Hello,
        now i have found a solution, the file [\AppData\Roming\Notepad++\nativeLang.xml] contains the selected GUI-language.
        A litle sourcecode arount and its work fine: ;-)

        The C#-function give back the implement short language id:

            private String getLanguage()
            {
                String result = "";
                StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);
                Win32.SendMessage(PluginBase.nppData._nppHandle,
                                                      (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, 
                                                      Win32.MAX_PATH, sbIniFilePath);
                String iniFilePath = sbIniFilePath.ToString();
                if (iniFilePath.EndsWith(@"plugins\Config"))
                {
                    iniFilePath = iniFilePath.Replace(@"\plugins\Config", @"\nativeLang.xml");
                    String readline = null;
                    Int16 counter = 0;
                    //    <Native-Langue name="English" filename="english.xml" version="6.8.2">
                    using (System.IO.StreamReader fileReader = System.IO.File.OpenText(iniFilePath))
                    {
                        while (counter < 30) // check counterMax
                        {
                            readline = fileReader.ReadLine();
                            counter++;
                            if (readline.ToLowerInvariant().Contains("<native-langue"))
                            {
                                string[] split = Regex.Split(readline, 
                                     "^(.*)(<Native-Langue)(\\s+)(name=\")(((?!\").)*)(\")(.*)$");
                                if ((split != null) && (split.Length > 4))
                                    readline = split[5];
                                else
                                    readline = null;
                                counter = 31; // Set counter to => max
                            }
                            else
                                readline = null;
                        }
                        fileReader.Close();
                    }
                    if (readline != null)
                    {
                        switch (readline.ToLowerInvariant())
                        {
                            case "deutsch":
                                result = "DE";
                                break;
                            case "english":
                                result = "EN";
                                break;
                            default:
                                result = "EN";
                                break;
                        }
                    }
                }
                return result;
            }
        

        regards Mario

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors