I created a WPF test project, single Window with a single button in it. I then unloaded the project and modified the csproj to contain the following <UICulture>en-US</UICulture>. After rebuilding the build folder now contains a subfolder named en-US and it contains a file called WpfLocalizationTest.resources.dll. All clear so far.
Then I downloaded the source code for Locbaml and built it. (Couldn't find a binary download anywhere, go figure.)
Then I copied the Locbaml.exe to the en-US folder and tried the following.
locbaml /parse WpfLocalizationTest.resources.dll /out:test.csv
This results in an error 'Could not load file or assembly WpfLocalizationTest.resources.dll or one of its dependencies. An attempt was made to load a program with an incorrect format.'
In the obj\x86\Debug folder there's a file called WpfLocalizationTest.g.en-US.resources. I tried running locbaml on that, but the result was the same.
How is locbaml supposed to be used? MSDN is full of cockamamie samples, none of which work. Is locbaml really how Microsoft intends WPF apps to be localized? Or have they come up with proper tools for the job?
As I continue to search I found another link here on Stackoverflow. The compile errors we were originally receiving were related to an outdated LocBaml project not being set for .Net4.0. This is why I was unable to generate teh CSV from the DLL and had to go straight at the resource file. Follow this link for more details. Locbaml localization of .net wpf4 application
This link provides a link to .net 4 binaries which once compilied allow you to go straight at the dll to generate the CSV using LocBaml.
Just an update I pulled my notes this morning. Hopefully this will help get you a bit further along.
Once the project has been compiled copy the LocBaml.exe to the project directory where the build has been generated : In my instance I copied the file to E:\localiztion_sample\localiztion_sample\obj\x86\Release
This is the tricky part in that the build did not contain all the DLL files from the bin directory (telerik controls and other assemblies). As a result I went to bin\release\ and copied all the DLL and resource files from there into the obj\x86\Release directory. For files where I was prompted to overwrite I looked to see if there was a difference in filesize or date created and if not I skipped the copy for these objects.
NOTE: In order for me to generate the CSV I had to copy dll and resource files from the bin directory and place them in the obj directory. Omitting this step will result in the CSV file being created but not populated with data.
Once you have copied the necessary files to the directory you will then parse the .resource file located within the Release directory.
In my project the resource file was located at:
E:\localiztion_sample\localiztion_sample\obj\x86\Release
And the file name was titled: localiztion_sample.g.en-US.resources
Note: this is different from the instruction on the Microsoft website. Microsoft states that you should run the LocBaml tool on the dll file located within the en-US directory. However after multiple attempts and research I found that this in fact caused a number of problems with compatibility between 32 and 64-bit builds as well as it just flat out not working.
In reading through wpf4 unleashed as well as online forums it is suggested to instead point to the *.gen.en-Us.resources file. * = the project name and gen.en-Us reflects the development language chosen
Within the VS command untility you will then need to enter the following
LocBaml /parse filename.resources /out: sample-en.csv
Notes: It is assumed that you have copied the LocBaml file to the root directory where this file exists and that you are running the command prompt as system administrator. For ease of use I changed the working directory within the command prompt to the VS project directory
For my sample project the command looked as:
*LocBaml /parse localization_sample.g.en-US.resources /out: sample-en.csv*
This command then generates the CSV file which acts as a definition of the current project
This was as far as I got I was able to modify teh file and regenerate the dll but I was not able to get the culture to change within the application so I am still working on this piece. I'll reposte once I get it working.
1) Unload project you want to localise
2) Edit Project .cproj file
3) Add property group at the end of the last property group
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
en-GB
4) Reload project and compile this would create a satellite assembly "yourlibrary.resources.dll" inside en-GB folder at bin\debug location, this assembly would be the default assembly.
5) Open Properties\AssemblyInfo.cs file and uncomment this line [assembly: NeutralResourcesLanguage("en-GB", UltimateResourceFallbackLocation.Satellite)] this is a fallback satellite assembly. And we need this entry otherwise for wpf application it throws exception around app.xaml.cs couldn't load
6) From command prompt run this command which uses msbuild to generate UID C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild /t:updateuid . \yourlibrary.csproj, open xaml file and check your controls there would be UID on all elements.
7) Download locabaml.exe source code tool from https://github.com/JeremyDurnell/locbaml
8) Copy locabaml.exe file to the \yourprojectname\bin\debug folder
9) we would now create an satellite assembly for french. First we need to parse the default satellite assembly and write out the contents to a csv file as shown here
10:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild /parse C:\yourprojectname\bin\Debug\yourlibrary.resources.dll /out:C:\yourprojectname\bin\Debug\yourlibrary.resources_FR.csv
11) Open yourlibrary.resources_FR.csv make necessary translations
12) Now we need to create a satellite assembly in french using command line
13) C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild /generate C:\yourprojectname\bin\Debug\yourlibrary.Resources.dll /trans: C:\yourprojectname\bin\Debug\yourlibrary.resources_FR.csv /out:C:\yourporjectname\bin\Debug\temp /cul:fr-FR
14) The command above would create a folder fr-FR at \bin\debug location
15) Switch your computer region settings to french(France)
16) In the code set localisation to Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
17) Compile and run application you would see translated text on the controls
Related
What does the xml .project and .cproject file contains ?
.rds_delta is a file which contains data like
#delete
.delta.lst
#add
#modify
author-signature.xml
signature1.xml
what is it's purpose?
There is another file .sdk_delta.info what does this contains
I would like to know the consequences of change in these file (each of these files).
You typically wouldn't change any of these files manually.
The .project file contains general settings for your project. Eclipse settings, whether the project is linked to another project, etc.
The .cproject contains C/C++-specific settings for your project. Build paths, build flags, which compiler to use, etc.
I have an inno setup code which works fine. Can anyone tell me how to make a bat file from an inno setup code so that a single click will initiate the installation set up.I have done that for java class files.Any help is appreciated.
There should be no need for a .bat file. Inno Setup creates a stand-alone executable (by default named Setup.exe) that you can simply double-click like any other Windows executable.
The executable it creates is nameable either by renaming the Setup.exe to a different name (YourAppSetup.exe, for instance) manually, or by using the OutputBaseName value in the [Setup] section. You can control where the setup executable is created by using the [Setup] section value OutputDir. Here's an example, from the CodeExample1.iss' sample provided in yourInno Setup` installation:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={code:MyConst}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
InfoBeforeFile=Readme.txt
OutputDir=userdocs:Inno Setup Examples Output
This creates the default Setup.exe in the userdocs: (your My Documents folder), in a subfolder named Inno Setup Examples Output. To put it somewhere else, just change the OutputDir entry to a different location. For instance, to put it in a sub-directory of your source folder named Installer, just use
OutputDir=Installer
For more info, see the documentation, in the Setup Script Sections->[Setup] Section Directives branch.
To change the name from Setup.exe to something else, add a new entry:
OutputBaseName=MyAppSetup
In my WPF caliburn.micro application, I use ComponentOne's C1DocumentViewer to display a report.
I created in the project a new Folder “Reports” and placed the .xml there. I show the report using C1DocumentViewer. When provide the absolute path to the .xml file, it works fine. But of course I need to use a relative path. So if I make it “../../MyProject/Reports/MyReport.xml”, it works on my machine when I run it in Visual Studio. But not when I publish it using ClickOnce, it just cannot find the file. Same thing if I use “/Reports/MyReport.xml” or “Reports/MyReport.xml”.
When I try to use “Reports/MyReport.xml” when I debug in Visual Studio, it is looking for the path “Reports/MyReport.xml” in bin/Debug of the main project of the solution.
Please help. Here is my code:
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
var rpt = new C1.C1Report.C1Report();
rpt.Load(#"Reports/MyReport.xml", "Recent Files Information");
rpt.DataSource.RecordSource = "MyReportProc(1)";
rpt.Render();
Report = rpt.FixedDocumentSequence;
}
Just a guess. Your problem might be related to the working directory of your process.
When the process refers to a file using a simple file name or relative
path (as opposed to a file designated by a full path from a root
directory), the reference is interpreted relative to the current
working directory of the process.
Check it with Directory.GetCurrentDirectory() when you run your program in Visual Studio and also when you run it after publishing it with ClickOnce.
I have a Solution that contain 3 projects.
1 Windows application and 2 class library.
Folder structure tree on my disc is as following:
\projects\CurrentProject\test\
\projects\CurrentProject\build\
The solution files are located under:
/projects/CurrentProject/
All 3 projects are located at \projects\CurrentProject\test\
I need all the build outputs of all projects (1.exe and 2 dlls) to be under \projects\CurrentProject\build\ ...
So on each project, i go to "project properties", select on both debug/release the output path to be: "....\build", but still after doing so, i have files on /obj of the class library projects.
Why is this ?
Thanks
To move your obj folder elsewhere your can customize your build configuration using the BaseIntermediateOutputPath property in the project file (the .csproj file).
To do it:
Open the .csproj file in a text editor (the .csproj file is an XML file)
Edit the value of the element BaseIntermediateOutputPath or add it in the desired PropertyGroup. (The line to modify or to add looks like <BaseIntermediateOutputPath>..\build\obj</BaseIntermediateOutputPath>)
Save the file
Reopen your project in Visual Studio.
I must confess I'm a bit of a noob when it comes to MSBuild and batch files, so do bear with me ;)
I have a folder structure which looks like this
/src
/SLProject
SLExampleProject.csproj
/WPFProject
WPFExampleProject.csproj
ExampleSolution.sln
Deploy.bat
The solution contains multiple silverlight WPF projects separate by folder at the level of /SLProject and /WPFProject. I am trying to create a batch file Deploy.bat to execute MSBuild on a subset of the Silverlight and WPF Projects, obfuscate the output and xcopy DLLs over to another folder.
I have a problem in my batch file related to MSBuild. When I specify both the Platform and Configuration for the first WPF Project to be build, I get the error "The OutputPath property is not set for project" ...
Here is the line of the batch file that causes the failure
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
/t:rebuild /p:Configuration=Release /p:Platform="Any CPU"
Abt.Controls.SciChart.Wpf/Abt.Controls.SciChart.Wpf.csproj
Any ideas what I'm doing wrong here? I can confirm there is an Output Path set for this project, and the combination of platform=release and configuration=AnyCPU exists for the project being built and its dependencies.
Curiously removing the Platform="Any CPU" and the build is successful ...
When building project files directly you must specify a Configuration and Platform combination that is defined in the project file. By default Visual Studio 2010 will only create Debug|x86 and Release|x86 for .NET projects. This isn't a problem when building from a solution file because by default it will map Platforms such as "Any CPU" or "Mixed Platforms" to one of the valid Platforms specified in the project files.
So you have two options, either specify "x86" for the Platform when building from your batch file or create a new Platform configuration for "Any CPU" for each project using the Configuration Manager in Visual Studio. Also, when you create an "Any CPU" Platform for a project it's actually called AnyCPU in the project file, so you will need to specify AnyCPU instead of "Any CPU" in your batch file. However, when building a solution from the command line you will still need to specify "Any CPU", just an annoying inconsistency.