1

Does anyone have an idea why my code is not working? I get English strings everywhere.

Note that is not an ASP.NET project but an actual WinForms project.

I have set up a windows forms project to use localization so that it will support Arabic and English languages.

 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

        Admin admin = new Admin();
        this.Close();
        admin.Show();

 Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-KW");

        Admin admin = new Admin();
        this.Close();
        admin.Show();

and I try this ;

            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
        this.Controls.Clear();
        this.RightToLeftLayout = false;
        InitializeComponent();
        Properties.Settings.Default["lang"] = "en-US";
        Properties.Settings.Default.Save();

            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-KW");
        this.Controls.Clear();
        InitializeComponent();
        Properties.Settings.Default["lang"] = "ar-KW";
        Properties.Settings.Default.Save();

It works when I test it by starting to debug but when I set up the application it stops working.

stuartd
  • 70,509
  • 14
  • 132
  • 163
ahmed_eltot93
  • 118
  • 16
  • 1
    _"it stops working."_ - what stops working? The app? The localization? And what does "set up the application mean"? Run an installer? – stuartd Apr 15 '19 at 12:35
  • The localization stop working. setup the application means run it outsit the VS @stuartd – ahmed_eltot93 Apr 15 '19 at 12:38
  • Add `Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("some-ietfCulture");`. (note that this is thread-based). Your context is not clear, though. You shoulf clarify what *when I set up the application* means. Also, you should probably use a resource file for each culture you support. – Jimi Apr 15 '19 at 12:38
  • how to use a resource file for each culture ?? @Jimi – ahmed_eltot93 Apr 15 '19 at 12:40
  • 1
    [Walkthrough: Localizing Windows Forms](https://web.archive.org/web/20140320171347/https://msdn.microsoft.com/en-us/library/y99d1cd3(v=vs.71).aspx) – stuartd Apr 15 '19 at 12:41
  • You form has a `Localizable` and `Language` properties you can find in the designer's properties panel. There are many resourses in SO about UI localization. You usually create a resource file that includes localization informations/strings/etc. The resource file is selected automatically when you change the current culture. – Jimi Apr 15 '19 at 12:46
  • do you mean WinFormStrings.en-US.resx and WinFormStrings.ar-KW.resx @Jimi – ahmed_eltot93 Apr 15 '19 at 12:49
  • 1
    [How to make multi language app in winforms](https://stackoverflow.com/a/32990088/7444103) -- [Software Internationalization](https://learn.microsoft.com/en-us/globalization/software-internationalization). – Jimi Apr 15 '19 at 12:50

1 Answers1

0

If your application works in debug mode and you can switch languages, then check the "bin\debug" folder and copy/deploy the language folder "ar" or "ar-KW" along with your EXE file on other machines Go to your debug folder and copy everything including all folders (except the .pdb) files to your target machine.

ahmed_eltot93
  • 118
  • 16