Change Locale at the runtime
2008-11-04 09:49
148 查看
Use ResourceBundle class and resourceManager method to change text and images at the runtime
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
creationComplete="{init()}"
xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import it.creativesource.ResourceLanguage;
private function init():void{
ResourceLanguage.setResources(resourceManager);
}
private function changeLocale(locale:String):void{
resourceManager.localeChain=[locale];
}
]]>
</mx:Script>
<mx:ApplicationControlBar width="400">
<mx:Image source="{resourceManager.getString('myResources','ICON')}" width="16" height="11"/>
<mx:Label text="{resourceManager.getString('myResources','TITLE')}" width="100%"/>
<mx:Button icon="@Embed('assets/us.png')" label="eng" click="changeLocale('en_US')" />
<mx:Button icon="@Embed('assets/it.png')" label="ita" click="changeLocale('it_IT')" />
</mx:ApplicationControlBar>
<mx:Text text="{resourceManager.getString('myResources','CONTENT')}" width="400" height="240"/>
</mx:Application>
The ResourceLanguage class:
package it.creativesource
{
import mx.resources.IResourceManager;
import mx.resources.ResourceBundle;
public class ResourceLanguage
{
public function ResourceLanguage()
{
}
public static function setResources(resourceManager:IResourceManager):void{
var myResources:ResourceBundle=new ResourceBundle("en_US","myResources");
myResources.content['TITLE']="Adobe Flex - English Version";
myResources.content['CONTENT']="Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich Internet applications based on the proprietary Adobe Flash platform. The initial release in March 2004 by Macromedia included a software development kit, an IDE, and a J2EE integration application known as Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services.";
myResources.content['ICON']="assets/us.png";
resourceManager.addResourceBundle(myResources);
myResources=new ResourceBundle("it_IT","myResources");
myResources.content['TITLE']="Adobe Flex - Versione Italiana";
myResources.content['CONTENT']="Adobe Flex è un insieme di tecnologie rilasciato da Adobe Systems per lo sviluppo e la diffusione del multi-piattaforma Rich Internet Applications basata sulla proprietà di Adobe Flash piattaforma. The initial release in March 2004 by Macromedia included a software development kit , an IDE , and a J2EE integration application known as Flex Data Services . La release iniziale nel marzo 2004 da Macromedia incluso un kit di sviluppo software, un IDE, e un J2EE integrazione domanda noto come Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services. Dato che Adobe ha acquisito Macromedia nel 2005, le successive versioni di Flex non necessitano più di una licenza per Flex Data Services, che è diventato un prodotto separato come rebranded LiveCycle Data Services.";
myResources.content['ICON']="assets/it.png";
resourceManager.addResourceBundle(myResources);
resourceManager.update();
}
}
}
引用:http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=11143&productId=2&loc=en_US
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
creationComplete="{init()}"
xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import it.creativesource.ResourceLanguage;
private function init():void{
ResourceLanguage.setResources(resourceManager);
}
private function changeLocale(locale:String):void{
resourceManager.localeChain=[locale];
}
]]>
</mx:Script>
<mx:ApplicationControlBar width="400">
<mx:Image source="{resourceManager.getString('myResources','ICON')}" width="16" height="11"/>
<mx:Label text="{resourceManager.getString('myResources','TITLE')}" width="100%"/>
<mx:Button icon="@Embed('assets/us.png')" label="eng" click="changeLocale('en_US')" />
<mx:Button icon="@Embed('assets/it.png')" label="ita" click="changeLocale('it_IT')" />
</mx:ApplicationControlBar>
<mx:Text text="{resourceManager.getString('myResources','CONTENT')}" width="400" height="240"/>
</mx:Application>
The ResourceLanguage class:
package it.creativesource
{
import mx.resources.IResourceManager;
import mx.resources.ResourceBundle;
public class ResourceLanguage
{
public function ResourceLanguage()
{
}
public static function setResources(resourceManager:IResourceManager):void{
var myResources:ResourceBundle=new ResourceBundle("en_US","myResources");
myResources.content['TITLE']="Adobe Flex - English Version";
myResources.content['CONTENT']="Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich Internet applications based on the proprietary Adobe Flash platform. The initial release in March 2004 by Macromedia included a software development kit, an IDE, and a J2EE integration application known as Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services.";
myResources.content['ICON']="assets/us.png";
resourceManager.addResourceBundle(myResources);
myResources=new ResourceBundle("it_IT","myResources");
myResources.content['TITLE']="Adobe Flex - Versione Italiana";
myResources.content['CONTENT']="Adobe Flex è un insieme di tecnologie rilasciato da Adobe Systems per lo sviluppo e la diffusione del multi-piattaforma Rich Internet Applications basata sulla proprietà di Adobe Flash piattaforma. The initial release in March 2004 by Macromedia included a software development kit , an IDE , and a J2EE integration application known as Flex Data Services . La release iniziale nel marzo 2004 da Macromedia incluso un kit di sviluppo software, un IDE, e un J2EE integrazione domanda noto come Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services. Dato che Adobe ha acquisito Macromedia nel 2005, le successive versioni di Flex non necessitano più di una licenza per Flex Data Services, che è diventato un prodotto separato come rebranded LiveCycle Data Services.";
myResources.content['ICON']="assets/it.png";
resourceManager.addResourceBundle(myResources);
resourceManager.update();
}
}
}
引用:http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=11143&productId=2&loc=en_US
相关文章推荐
- 运行时决定AAC硬件解码器可用性/Determining the availability of the AAC hardware encoder at runtime
- warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared librar
- AS- This view is not constrained vertically. At runtime it will jump to the left/(0,0) unless you
- How to disable VirtualBox time sync from within the guest at runtime
- CentOS 7 /RHEL 7: How To Change The System Locale
- linux gcc编译错误:statically linked applications requires at runtime the shared libraries
- How to Change .NET Configuration Files at Runtime (including for WCF)
- Code snippet of the day : Resizing ASP.NET Datagrid Controls in Edit mode at runtime
- How to change the price range in layered navigation in Magento? - See more at: http://www.expertweba
- System.Runtime.Remoting.RemotingException: has been disconnected or does not exist at the server
- How to change the EM OMS locale
- Changing the SiteMapDataSource’s XML filename at runtime
- modify the visual tree at runtime
- vyos bug - a tcp flow is working, and it will also working at the step you change the port or other
- change the DHCP address to static address at home
- EF6 Database First (DbContext) - Change Schema at runtime
- The process was terminated due to an internal error in the .NET Runtime at IP 7915EE73 (79140000) wi
- This view is not constrained vertically: at runtime it will jump to the left unless you add a vertic
- Using 'dlopen' in statically linked applications requires at runtime the shared libraries
- How to change size of WPF controls at runtime