WP7 中带有本地化支持的自定义控件 [英] Custom Control with Localization Support in WP7

查看:23
本文介绍了WP7 中带有本地化支持的自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了 DateTimePicker 控件.现在我想为此添加本地化支持.

我已按照以下步骤操作.

<块引用>

  1. 在 ResourceFolder 中创建了 CustomControls.de-DE.resx.
  2. 在该 resx 文件中添加了一些常用字符串
  3. 将访问修饰符更改为 Public
  4. 在 csproj 文件中添加了 de-DE;.
  5. set System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");在之前的 sample.cs 文件中初始化组件().
  6. 我的日期时间值为2 天:3 小时(s):5 分钟:32 秒(s)

仅获取英语的默认语言.

我做错了什么?请帮助我任何人.我错过了什么吗?

解决方案

在 WP7 中添加本地化支持的明确步骤

<块引用>

  1. 创建自定义控件.
  2. 在属性中添加 AppResource.resx
  3. 在属性中添加 AppResource.es.resx 和 Appresource.it.resx 文件
  4. 用唯一的名字添加需要的字符串.(我们可以参考这个id的字符串使用).
  5. 添加它;es;在 csproj 文件中.(卸载项目,右键单击->编辑,添加支持的文化标记然后重新加载它)
  6. 创建示例
  7. 对 Sample.csproj 文件执行与第 5 步相同的操作
  8. 在按钮单击中更改系统的文化.(例如:Thread.CurrentThread.CurrentUICulture = newSystem.Globalization.CultureInfo("de-DE");)
  9. 运行项目

参考:http://www.windowsphonegeek.com/articles/Localizing-a-Windows-Phone-app-Step-by-Step

谢谢.

I have created the DateTimePicker control. Now i want to add localization Support with this.

I have followed the below steps.

  1. Created CustomControls.de-DE.resx inside the ResourceFolder.
  2. added some commonly used strings in that resx file
  3. changed the access modifier to Public
  4. added <SupportedCulture>de-DE;</SupportedCulture> in the csproj file.
  5. set System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); in sample.cs file before IntializeComponent().
  6. my DateTimevalue was " 2 Day(s): 3 Hr (s): 5 Min(s) : 32 Sec (s)

Getting only default language that is english.

What i did wrong? Please help me anyone. Is anything i missed?

解决方案

Clear Steps To add Localization Supports in WP7

  1. Create Custom control.
  2. Add AppResource.resx inside Properties
  3. Add AppResource.es.resx and Appresource.it.resx files inside Properties
  4. Add needed strings with unique name.(we can refer the strings use of this id).
  5. Add it;es; in the csproj file.(unload the project, rightclick->edit, add the supportedculture tag then reload it)
  6. Create the Sample
  7. do the same as 5th step for Sample.csproj file
  8. Change the cultures of System in the button click.(Ex: Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");)
  9. Run the Project

Ref: http://www.windowsphonegeek.com/articles/Localizing-a-Windows-Phone-app-Step-by-Step

Thankyou.

这篇关于WP7 中带有本地化支持的自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆