The type or namespace name 'Form1' could not be found

Mar 15, 2011 at 11:19 AM

 

When I try a simple example in C# in Visual Studio2008, I get the following error:

error CS0246:
The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?)

Could you provide an example in C# ?

Thanks !

My sourcecode looks like this:

//
// Test Nlocalizer
// http://nlocalizer.codeplex.com/
//
using System;
using System.Windows.Forms;
using NLocalizer;

namespace NLocalizerTest1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Translator.Translation.Read();
        }

        private void englishToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Translator.Translate("English", this);
            Translator.Translate("English", (NLocalizerTest1.Form1) this);
            Translator.Translate("English");
        }

        private void dutchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Translator.Translate("Dutch", this);
            //Translator.Translate("Dutch", (NLocalizerTest1.Form1) this);
            Translator.Translate("Dutch");
        }

        private void germanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Translator.Translate("German", this);
            Translator.Translate("German", (NLocalizerTest1.Form1) this);
            Translator.Translate("German");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();       // Quit
        }


    }
}

 

 

Coordinator
Mar 15, 2011 at 11:40 AM
Edited Mar 15, 2011 at 11:47 AM

Example C# code is included in NLocalizer.Example project. Your .lang files need 4 header lines (see documentation):

locale pl-PL,
module System.dll, System.Windows.Forms.dll, NLocalizer.dll, NLocalizer.Example.exe,
using System, System.Windows.Forms, System.Reflection, NLocalizer, NLocalizer.Example,
static Messages,

Please replace "NLocalizer.Example" as Your project name and I think - it will fix Your error :)

You can remove (NLocalizerTest1.Form1) from lines like this:

Translator.Translate("German", (NLocalizerTest1.Form1) this);
Mar 15, 2011 at 2:06 PM

 

Thanks KAP, that helped !

It would be nice though if there was some documentation included with your otherwise impressive project.

Something like this:

 NLocalizerApp.exe
  Import *.Designer.cs
  Read .cs files
  Get translation
  Write .cs files -> private to public controls
  Choose Form
  Save
 
 Copy English.lang to Dutch.lang
 Edit Dutch.lang
 change header: locale nl-NL
 Change "NLocalizer.Example" to your program name
 
 Visual Studio
 R-Click References - Add reference - Nlocalizer.dll
 R-Click Project - Add Existing Item - Dutch.lang
 Properties - Copy if newer

 

Groetjes uit Nederland ...

Coordinator
Mar 16, 2011 at 6:37 AM
Edited Mar 16, 2011 at 7:53 AM

Thanks!

I inserted Your todo list in top of documentation. I will be happy for any further constructive suggestion :)

Coordinator
Sep 2, 2011 at 3:27 PM
Edited Sep 2, 2011 at 3:31 PM

NLocalizer 1.7+ autodetect necessary libraries and don't need any module or using definition.