卫星组装部署
我正在尝试使用卫星程序集本地化我的 Windows Phone 7 应用程序。 构建了
(al /t:lib /embed:stringlibrary.it-It.resx /culture:it /out:PhoneApp2.resources.dll /template:PhoneApp2.dll)
我从资源文件 stringlibrary.it-It.resx
为我的应用程序 PhoneApp2 一个 dll“PhoneApp2.resources.dll”,然后下载了该 dll 使用 webclient 并存储在应用程序 PhoneApp2 的 it-IT 目录中。现在 dll 驻留在phoneapp2 的isolatedstorage 中。
我有另一个资源文件 stringlibrary.resx ,它总是与应用程序一起编译,并包含英语支持条目(默认)。
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("it-IT\\"+resfile, System.IO.FileMode.Create, file))
{
byte[] buffer = new byte[1024];
while (e.Result.Read(buffer, 0, buffer.Length) > 0)
{
stream.Write(buffer, 0, buffer.Length);
}
}
我在程序集文件中也有条目 [程序集:NeutralResourcesLanguageAttribute("it-IT", UltimateResourceFallbackLocation.Satellite)] 。
即使当前的语言和文化是意大利语,它总是在消息框中向我显示中性语言文本(英语)。 这意味着它无法找到卫星组件。
rm = new ResourceManager("PhoneApp2.stringlibrary", Assembly.GetExecutingAssembly());
string greeting = rm.GetString("String1");
MessageBox.Show(greeting);
但是,如果我使用 PhoneApp2 而不是卫星程序集编译 stringlibrary.it-It.resx ,则消息框会正确显示意大利语文本 当文化是意大利文化和英语文化时。我在部署卫星组件时遗漏了什么吗?请告诉我。
问候, 森蒂尔
I am trying to localize my windows phone 7 application using satellite Assemblies. I have built
(al /t:lib /embed:stringlibrary.it-It.resx /culture:it /out:PhoneApp2.resources.dll /template:PhoneApp2.dll)
a dll "PhoneApp2.resources.dll" for my application PhoneApp2 from a resource file stringlibrary.it-It.resx
and then i downloaded the dll
using webclient and stored in a directory it-IT from app PhoneApp2 .Now the dll resides in phoneapp2's isolatedstorage.
I have another resource file stringlibrary.resx which always gets compiled with application and had entries for english support(default).
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("it-IT\\"+resfile, System.IO.FileMode.Create, file))
{
byte[] buffer = new byte[1024];
while (e.Result.Read(buffer, 0, buffer.Length) > 0)
{
stream.Write(buffer, 0, buffer.Length);
}
}
I have the entry [assembly: NeutralResourcesLanguageAttribute("it-IT", UltimateResourceFallbackLocation.Satellite)] in assembly file as well.
It always shows me neutral language text (english) in the Messagebox even though the current language and culture is italian.
That means it is not able to find the satellite assembly.
rm = new ResourceManager("PhoneApp2.stringlibrary", Assembly.GetExecutingAssembly());
string greeting = rm.GetString("String1");
MessageBox.Show(greeting);
But if i compile stringlibrary.it-It.resx
with PhoneApp2 instead of satellite assembly, the Messagebox displays the italian text properly
when culture is italian and english for english cuture. Am i missing something in deploying satellite assemblies? Pls let me know.
Regards,
Senthil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法在已下载到独立存储中的应用程序中使用程序集。只有 Microsoft 签名的程序集(因此提交时已在 XAP 中的那些程序集)才能在运行时加载/执行。
如果您想随后下载其他翻译,您应该使用 resx 文件或任何其他可以自行解析的格式。我的建议是对所有资源字符串使用某种数据库,然后将新下载的数据添加到该数据库中。这比您想要实现的目标更加灵活:)
You cannot use assemblys in your App you have downloaded into the isolated storage. Only assemblys signed by Microsoft (thus those assemblys already in your XAP on submission) can be loaded / executed on runtime.
If you want to download additional translations afterwards you should go with resx-files or any other format you can then parse on your own. My suggestion would be to use some kind of database for all resource strings and then add the newsly downloaded data into this db. This is way more flexible then what you are trying to accomplish :)
我还没有尝试过按照您的方式进行本地化。对我来说,这似乎过于复杂。但我已经本地化了几个应用程序,并且鉴于我很难找到完整的源代码,因此我将其写在博客上。这是我的博客: http://hopnet.mobi/website/Blog.aspx
基本上你这样做:
I have not tried localizing in the way that you're doing it. To me it seems overly complicated. But I have localized several apps, and given that I had a hard time finding a complete source how to do it, I blogged it. Here's my blog: http://hopnet.mobi/website/Blog.aspx
Basically you do this: