Been a while since I have localized a WinForm project.
Must be missing something really basic.
Made a Hello World Winform project (VS2008) to refresh myself.
(Production project is in VS2013)
All the documentation I find says that the form has a localizable property which needs to be set to true.
But I can't find it.
(I want to use localized resx files for each form in the production project to set the Text of controls. I can create the resx files but the forms are ignoring them.)
Could someone please point me in the right direction?
I can see that property in Properties window in VS2013:
and in VS2008:
Related
I am probably facing a basic problem. I would like to create TimePickers as in this project link: TimePickerProject
This project was given as reference in one of the Stack overflow answers Stack OverflowAnswer
You can download and directly run that project really easy. But couldn't add it to my own project as an independent TimerPicker Object. TimePicker class is inside Opulos folder. As you can see Opulos folder is copy pasted to my own project.
I
And I can see that Timepicker inside my toolbox.
But when I try to drag it to my panel I am facing with this error.
To explain this process more clearly:
Just paste the Opulos folder into the root directory of your program. (I am here. Net framework 4.8 winform)
Edit Opulos/Core/UI/TimePicker.cs
Add the below codes:
public TimePicker() :this(3, true, true, true, true) {
}
Then rebuild the program, you could find it in the toolbox.
Output:
Thanks to jimi's explanation:
Pass default values or configure it to generate a different pre-defined behavior when the class is created via ToolBox.
Keep in mind that those classes are not built with the ToolBox in mind (no reference to ToolBox behavior is specified anywhere), it looks like all are meant to be instantiated in code.
I.e., you may have the same problem somewhere else.
You should know what to do (though decorating the public Control classes with appropriate [ToolboxItem], [ToolboxBitmap] etc. stuff should be considered)
If you are trying to drag another folder into your solution folder, then you can use the default windows file explorer. If you want to import a library from another project, simply right click Dependencies->add project reference, browse, and select the library. In general, you should avoid copying the code itself, and instead add a reference to the output.
Hope I could help, if I misunderstood your question I apologize!
My C# project displays classes in the Solution Explorer some with the Designer View and some with the normal code editor:
AND
I Would like to make them all open with the code editor!
I went in the .csproj file and I noticed that for the classes marked as designer, I get a
<SubType>Component</SubType> tag. If I remove it manually, VS automatically re-add it to the item.
How to solve it? I searched but did not found anything usefull..
EDIT 1: I forgot to mention that this is a Console Application
I am trying to localize a Xamarin Forms app. I followed all the steps included here: https://developer.xamarin.com/guides/xamarin-forms/localization/
However, in the Android Emulator, after changing the default language, the strings do not get displayed, they remain the default language. On the device the app doesn't even launch.
Steps taken so far:
1) tried breakpoint (BP) in the main launcher, it skipped the BP and entered the main page
2) tried BP on the Localize class, it doesn't reach it
3) tried BP on the Device.OS check, skips it.
The resource files in Visual Studio are the following:
AppResources.resx
AppResources.fr.resx
AppResources.es.resx
Anyone ever succeeded localizing a Xamarin Forms app before ? I need some assistance with this as Visual Studio does not raise any exception ...
UPDATE 1 :
The resource files in Visual Studio are the following:
AppResources.resx
AppResources.fr_FR.resx
AppResources.es_ES.resx
UPDATE 2:
After recent suggestions and modifications I have the following exception: Markup extension not found.
This is disturbing as the markup extension class is there.
Doesn't work in DEBUG mode (Android only)
If the translated strings are working in your RELEASE Android builds
but not while debugging, right-click on the Android Project and select
Options > Build > Android Build and ensure that the Fast assembly
deployment is NOT ticked. This option causes problems with loading
resources and should not be used if you are testing localized apps.
SOLVED:
The problem was in the declaration of the extension. In a PCL project, the following took place:
a) the TranslateExtension class is located in a subfolder named Pages
b) initial declaration was
xmlns:languages="clr-namespace:MyApp;assembly=MyApp"
c) the following declaration solved the problem:
xmlns:languages="clr-namespace:MyApp.Pages;assembly=MyApp"
along with language code naming conventions of the .resx files as mentioned above
2021 UPDATE
All the current answers are not valid anymore! You need to add resources. Right click your xamarin forms project (Not xamarin android or ios) => Go to project properties ==> Resources ==> Add Resource.
This will create a "Properties" Folder and a resources.resx file which you can delete if you want to.
Then follow the official microsoft documentation by creating a AppResources.resx and other language files (such as AppResources.ar.resx file for arabic). All these files MUST BE in the properties folder.
Then, in your XAML page, declare the namespace as:
xmlns:res="clr-namespace:YourProject.Properties"
Then simply use:
<Label Text="{x:Static res:AppResources.Address}" >
This will use the corresponding Language files depending on what language the device is using. If the language is not supported it will use the defulat file (AppResources.res)
FIUH!!! Wasted one hour to solve this!!!
The problem concerns Windows Forms.
I have no idea how to do it. I've tried following:
1) Add a Bitmap (CarControl.bmp) do the solution, then set BuildAction to Embedded Resource and add the ToolBoxBitmapAttribute like:
[ToolboxBitmap(typeof(CarControl),"CarControl")]
2) Going into Properties, then in Resources section I've added some images. Still doesn't work.
Can anybody help?
Naming is very important, otherwise it does not work.
[ToolboxBitmap(typeof(CarControl), "Resources.CarControl.png")]
Another important note:
If you open the solution of your CarControl you will always see the default gear icons for the controls of your actual build. But if you make a build and you add the controls of this (released) library to the Toolbox either by drag-and-dropping the dll or by Right click/Choose Items..., then the icon will appear.
If you did everything well, you will able to find the embedded resource in the compiled .dll when you open it with Reflector or other disassembler tool. The following example is from System.dll:
You should find a <DefaultNamespace of your project>.<Your resources folder>.CarControl.png here.
We have successfully localized our windows-forms application. One form refuses to use the localized resources and is always shown with the embedded resources. I checked the following points:
The forms Localizable attribute is true
At runtime the UI-culture is set correctly
The satellite assembly is in the correct location
With SysInternals process explorer I verified that the process uses the satellite assembly
I opened the satellite assembly with IL-Spy and checked that it contains the translated resources
In the debugger I stepped into Microsofts ComponentResourceManager.ApplyResources Method for a button. It finds the text property but as the code is optimized I cannot see the really interesting things.
All other forms (different assemblies) appear with the correct language, only this one ...
I hope someone out there has a helpful idea.
Just stumbled upon the same issue but could solve it.
I just imported the localized resx files into the project. So the *.de.resx were part of the project, but the localized resources were not applied to all forms.
Referring to http://msdn.microsoft.com/library/y99d1cd3%28v=vs.110%29.aspx, the localized resource files should appear beneath the form (as a sub item).
So my solution was:
- go through all forms, change language from Default to German and back to Default.
- as a result, the *.de.resx files were listed as sub items of the forms
- then overwrite the just created *.de.resx files with the localized ones
Then it works for all forms. I have no idea, though, why it worked before for 3 forms out of 4.
What is the recommended way to add a new language to a Windows Forms application? Do I really need to click through all forms of my application for creating the empty resx files for the new language? Of course, I could edit the project file manually...