注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

姑射道人的博客

博客新地址:nixuchen.com

 
 
 

日志

 
 

Localization for Images and Assets  

2013-07-09 16:37:58|  分类: windows phone |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Introduction

This sample shows who to localization images.

Some applications need to add images for each language that application supports. In this sample you can see how to localize images from Assets folder (where is defined all logos and splash screen image) and other images that are in other folder, for example Resources folder (but can be other name).

The sample covers XAML code, C# code and appManifest file.

Building the Sample

You only need Visual Studio 2012 and Windows 8, both the RTM version. 

Description

In the first step we need to add the images in each folder like we see in the following picture:

 

And we need to add the resource file (*.resw) for each language you want the application supports.

You can see the topic: Creating resource files in Creating and retrieving resources in Windows Store apps

 

The second step is to define in manifest the logos path:

 

In the MainPage.xaml ans MainPage.xaml.cs you can see how to add the images:

C#
// Case 1 
// Here is added the default image 
// but is showed the right image  
// (in this sample, shows the english image or  portugueses image) 
<Image Source="Assets/Logo.png"/> 
 
// Case 2 
 
// the SourceForImageLogo is to represent the  
// SourceForImageLogo.Source value in *.resw file 
// in english case is: Assets/en-US/Logo.png 
//this case is not necessary because the last case is better 
<Image x:Uid="SourceForImageLogo" /> 
 
// Case 3 
// in code behind you can add the image doing the //following 
var imageUriForlogo = new Uri("ms-appx:///Assets/Logo.png"); 
logoImage.Source = new BitmapImage(imageUriForlogo); 
 
For the image from de the Resource folder is similar. See in the solution.
Notes:
Suppose you install the application when your computer is in English, it should show all images for the english version. If you switch for portuguese language it show the logos in english but the content is loading in Portugueses. Another situation is when you unistall the application.

 

Related Sample

Application resources and localization sample

 

Related Topics

Creating and retrieving resources in Windows Store apps

Using the Manifest Designer (Windows Store apps)

 

Build the sample

  1. Start Visual Studio Express 2012 for Windows 8 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2012 for Windows 8 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

 

  评论这张
 
阅读(509)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017