How does Locbaml work?

前端 未结 3 1781
迷失自我
迷失自我 2021-01-04 22:00

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 e

3条回答
  •  粉色の甜心
    2021-01-04 22:22

    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.

提交回复
热议问题