卫星组装部署

发布于 2024-12-01 20:29:04 字数 1256 浏览 4 评论 0原文

我正在尝试使用卫星程序集本地化我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦纸 2024-12-08 20:29:04

您无法在已下载到独立存储中的应用程序中使用程序集。只有 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 :)

淡紫姑娘! 2024-12-08 20:29:04

我还没有尝试过按照您的方式进行本地化。对我来说,这似乎过于复杂。但我已经本地化了几个应用程序,并且鉴于我很难找到完整的源代码,因此我将其写在博客上。这是我的博客: http://hopnet.mobi/website/Blog.aspx

基本上你这样做:

  1. 创建项目
  2. 在记事本中编辑.csproj文件,将所需的区域性添加到标签中。
  3. 在项目属性中选择中性区域性
  4. 将资源添加到解决方案资源管理器中的项目
  5. 创建一个类来访问这些资源
  6. 将该类添加到 App.xaml 文件的标记中
  7. 将字符串放入资源文件中
  8. 使用资源绑定绑定到这些字符串在你的 xaml 中。
  9. 如果使用 ApplicationBar,则必须在代码中执行此操作,因为它无法绑定在 xaml 中。
  10. 为每种支持的区域性创建另一个资源文件。
  11. 为每种支持的语言创建 dll 文件,以便磁贴和程序列表上的标题正确。

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:

  1. Create the project
  2. Edit the .csproj file in notepad to add the desired cultures to the tag.
  3. Select a neutral culture in the project's properties
  4. Add Resources to the project in Solution Explorer
  5. Create a class to access those resources
  6. Add that class to the tag of the App.xaml file
  7. Put your strings into the Resources file
  8. Bind to those strings using the resource binding in your xaml.
  9. If using an ApplicationBar, you must do so in code, as it cannot be bound in xaml.
  10. Create another resource file for each supported culture.
  11. Create dll files for each supported language, so the title will be correct on the tile and program list.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文