[英]Localizing with satellite assemblies
我正在嘗試使用附屬程序集在WinForms應用程序中進行本地化。 目錄結構如下:
在Program.exe中,此代碼在Main
方法中執行:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
Application.Run(new Form());
我檢查了FUSLOGVW.exe的輸出:
*** Assembly Binder Log Entry (5/30/2012 @ 5:19:37 PM) *** The operation failed. Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable D:\tmp\bin\Program.exe --- A detailed error log follows. === Pre-bind state information === LOG: User = paulius_l LOG: DisplayName = Program.resources, Version=1.0.0.0, Culture=de, PublicKeyToken=... (Fully-specified) LOG: Appbase = file:///D:/tmp/bin/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = Program.exe Calling assembly : Program, Version=1.0.0.0, Culture=neutral, PublicKeyToken=.... === LOG: Start binding of native image Program.resources, Version=1.0.0.0, Culture=de, PublicKeyToken=.... WRN: No matching native image found. LOG: IL assembly loaded from D:\tmp\bin\de\Program.resources.dll.
看起來不錯,但是字符串只是未本地化-仍使用Program.exe中的默認字符串。
為了獲得字符串,我使用了Visual Studio從Res.resx
生成的Res
類。
我在這里想念什么?
編輯:為那些比我更了解它的人添加了完整的FUSLOGVW輸出。
這是我編寫自動生成腳本以在外部生成附屬程序集時犯的一個巨大錯誤。 問題是在生成附屬程序集中的類時,我錯過了Res
類。 難怪它沒有用。
花了很長時間后,今天早上我發現了問題。
我相信您的文化標識符在此行上是錯誤的:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
CultureInfo的區域性標識符采用“ languagecode-countrycode”的形式。 例如,“ en-US”代表美國英語,“ en-GB”代表英國/英國英語。
嘗試“ de-DE”。
在http://msdn.microsoft.com/zh-cn/library/system.globalization.cultureinfo.name%28v=vs.95%29.aspx和http://msdn.microsoft.com/ zh-cn / goglobal / bb896001.aspx ,以獲取區域性標識符列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.