LangLib Instructions

Windows Forms

Inheritance from a System.Windows.Forms.Form should be changed as follows:

using VPKSoft.LangLib;

 

namespace WindowsFormsApplication1
{
    public partial class Form1 : DBLangEngineWinforms
    {
        public Form1()
        {
            InitializeComponent();
            DBLangEngine.DBName = "WindowsFormsApplication1.sqlite";
            if (Utils.ShouldLocalize() != null)
            {
                DBLangEngine.InitalizeLanguage("WindowsFormsApplication1.Messages", Utils.ShouldLocalize(), false);
                return; // After localization don't do anything more.
            }


            DBLangEngine.InitalizeLanguage("WindowsFormsApplication1.Messages");

 

WPF / XAML

With WPF the inheritance is a bit more complex procedure, but once done it stays..

using VPKSoft.LangLib;

namespace WPFApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1: VPKSoft.LangLib.DBLangEngineWPF
    {
        public Window1()
        {
            InitializeComponent();

            DBLangEngine.DBName = "WPFApplication1.sqlite";
            if (Utils.ShouldLocalize() != null)
            {
                DBLangEngine.InitalizeLanguage("WPFApplication1.Messages", Utils.ShouldLocalize(), false);
                return; // After localization don't do anything more.
            }
            DBLangEngine.InitalizeLanguage("WPFApplication1.Messages");

 

After this we need to modify the xaml:

<VPKSoft:DBLangEngineWPF x:Name="Window1" x:Class="WPFApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:VPKSoft="clr-namespace:VPKSoft.LangLib;assembly=VPKSoft.LangLib"
        Title="LangLibTestWPF" Height="309" Width="460" Icon="images/VPKSoft.ico">

 

 

So we link the Langlib library to the xaml by giving it a a xml namespace. NOTE: The namespace does not need to be VPKSoft.

xmlns:VPKSoft="clr-namespace:VPKSoft.LangLib;assembly=VPKSoft.LangLib"

After that we inherit the change the Window1: Window to

VPKSoft:DBLangEngineWPF

Just remember to keep those VPKSoft's as in VPKSoft == VPKSoft..

 

Program.cs

We need to modify this file so that the localization "dump" may take place.

For Windows Forms

using VPKSoft.LangLib;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (Utils.ShouldLocalize() != null) // Localize and exit.
            {
                new Form1();
                return;
            }
            Application.Run(new Form1());
        }
    }
}

So we don't let the application to start if a command line parameter --dbLang or --dbLang=cu-RE (ISO 639-1) was given.

 

For WPF / XAML

using VPKSoft.LangLib;

namespace WPFApplication1
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (Utils.ShouldLocalize() != null) // Localize and exit.
            {
                new Window1();
                System.Diagnostics.Process.GetCurrentProcess().Kill(); // self kill after localization
                return;
            }
        }
    }
}

So with WPF we instruct the application to "kill self" if a command line parameter --dbLang or --dbLang=cu-RE (ISO 639-1) was given.

 

One embedded resource 

As the was some talk about not needing any resources, a one is required.

This is to store the inside application messages such as a message shown in a MessageBox.

You may name it anything you want. Here is a sample:

 

Just remember to call the LangLib with the right resource name. If your application namespace is for example WindowsFormsApplication1 

you should tell the application to initialize with a the resource name:

DBLangEngine.InitalizeLanguage("WindowsFormsApplication1.Messages");

 

Download as a document

There are to document formats which I will support. One is LibreOffice (.odt) and another is

Portable Document Format (.pdf). If you wish, you can edit the LibreOffice file and send it to me

for an update.

{phocadownload view=file|id=29|target=s}

{phocadownload view=file|id=30|target=s}

 

That's it

I hope this help file was instructional enough to start localizing. tongue-out