<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>google code &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/google-code/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Mon, 14 Jun 2010 21:36:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>google code &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>ActionScript 3.0, first attempt</title>
		<link>https://blog.sephiroth.it/2005/12/06/actionscript-3-0-first-attempt/</link>
					<comments>https://blog.sephiroth.it/2005/12/06/actionscript-3-0-first-attempt/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Tue, 06 Dec 2005 19:08:11 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[gettext]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[google code]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=119</guid>

					<description><![CDATA[gettext actionscript
]]></description>
										<content:encoded><![CDATA[<p>Finally I found the time (not so much) to play a little with <a href="http://labs.macromedia.com/wiki/index.php/Flex_Builder">Flex 2</a> alpha and <a href="http://labs.macromedia.com/wiki/index.php/ActionScript_3">ActionScript 3.0</a>.<br />
In particular I falled in love with the so long awaited <a href="http://livedocs.macromedia.com/labs/1/flex/langref/flash/util/ByteArray.html">ByteArray</a> class, which let us to do bytes operations 🙂<br />
So I&#8217;ve created a porting of the GNU gettext class for ActionScript. I&#8217;ve got this wish since a long long time, but it was always impossible without the new ByteArray class.<br />
For the complete article read <a href="http://www.sephiroth.it/phpwiki/index.php?title=Gettext_actionscript3">here</a>, also for an explanation of gettext.</p>
<p>The project is hosted on google code <strong><a href="http://code.google.com/p/sepy-gettext/">here</a></strong>.</p>
<p>and this is the code I&#8217;ve used in flex:</p>
<pre class="tutorialCode">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" creationComplete="main()"&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
import flash.events.*;
import flash.utils.trace;
import i18n.gettext;
import flash.net.*;
import mx.controls.*;
import mx.controls.gridclasses.DataGridColumn
var ln:gettext;
var alert:Alert;
var added:Boolean;
/**
* init gettext
*/
public function init_gettext()
{
ln = new gettext();
ln.addEventListener("complete", this.handleEvent);
ln.addEventListener("ioError",  this.handleEvent);
ln.addEventListener("error",    this.handleError);
set_locale("it");
}
public function set_locale(lang:String)
{
alert = Alert.show("Please wait while loading locale dictionary file", "Loading...", Alert.NONMODAL, this, null, null);
ln.translation("SEPY", "http://www.sephiroth.it/_temp/flex/gettext/locale/", lang);
ln.install();
log("innstall('" + lang + "')");
}
/**
* items for the combobox component
*/
public function get_avail_languages():Array
{
var data:Array = new Array();
data.push({label: _(gettext.FindLanguageInfo("it")), data:"it"});
data.push({label: _(gettext.FindLanguageInfo("en")), data:"en"});
data.push({label: _(gettext.FindLanguageInfo("de")), data:"de"});
data.push({label: _(gettext.FindLanguageInfo("zh_cn")), data:"zh_cn"});
data.push({label: _(gettext.FindLanguageInfo("zh_tw")), data:"zh_tw"});
data.push({label: _(gettext.FindLanguageInfo("nl")), data:"nl"});
data.push({label: _(gettext.FindLanguageInfo("fr")), data:"fr"});
data.push({label: _(gettext.FindLanguageInfo("pt")), data:"pt"});
return data;
}
/**
* items for the datagrid component
*/
public function get_dataprovider():Array
{
var data:Array = new Array();
data.push({label:"Add new folder", data:_("Add new folder")})
data.push({label:"An Error occurred, or the package need to be recompiled first", data:_("An Error occurred, or the package need to be recompiled first")})
data.push({label:"Are you sure?", data:_("Are you sure?")})
data.push({label:"Add @see if extended class (must be listed in the tags list)", data:_("Add @see if extended class (must be listed in the tags list)")})
data.push({label:"Browse new package", data:_("Browse new package")})
data.push({label:"Capture output", data:_("Capture output")})
data.push({label:"Cannot wrote to filesystem", data:_("Cannot wrote to filesystem")})
data.push({label:"Cannot read file, invalid zip file", data:_("Cannot read file, invalid zip file")})
data.push({label:"Cannot modify read-only document", data:_("Cannot modify read-only document")})
data.push({label:"Choose application", data:_("Choose application")})
return data;
}
/**
* main HandleEvent Responder
* handle all the event dispatched
*/
public function handleEvent(event:Event){
this.log("event: " + event.type);
switch(event.type)
{
case "click":
if(event.target.name == "button_1")
{
var mc:ComboBox = ComboBox(this.h_box_1.getChildByName("combo_languages"));
this.set_locale(mc.selectedItem.data);
} else {
this.callLater(init_gettext);
}
break;
case EventType.COMPLETE:
alert.visible = false;
if(!this.added)
{
var combo:ComboBox = new ComboBox();
var label:Label    = new Label();
var button:Button  = new Button();
var dp:DataGrid = new DataGrid();
var col_1:DataGridColumn = new DataGridColumn();
var col_2:DataGridColumn = new DataGridColumn();
var label_2:Label = new Label();
var hrule:HRule = new HRule()
button.name = "button_1"
button.addEventListener("click", this.handleEvent);
combo.name = "combo_languages";
label.name = "label_1";
this.h_box_1.addChild(label);
this.h_box_1.addChild(combo);
this.h_box_1.addChild(button);
dp.name = "datagrid_1";
dp.width = 560;
col_1.columnName = "label";
dp.addColumn(col_1);
col_2.columnName = "data";
col_2.headerText = _("Translation")
dp.addColumn(col_2);
label_2.name = "label_2";
hrule.width = 560;
this.v_box_1.addChild(label_2);
this.v_box_1.addChild(hrule)
this.v_box_1.addChild(dp);
this.added = true;
}
Button(this.h_box_1.getChildByName("button_1")).label = _("Change to");
Label(this.h_box_1.getChildByName("label_1")).text    = _("Language") + ": ";
Label(this.v_box_1.getChildByName("label_2")).text    = _("Test project");
ComboBox(this.h_box_1.getChildByName("combo_languages")).dataProvider = this.get_avail_languages();
DataGrid(this.v_box_1.getChildByName("datagrid_1")).dataProvider = this.get_dataprovider();
DataGrid(this.v_box_1.getChildByName("datagrid_1")).getColumnAt(0).headerText = _("Select items");
break;
default:
break;
}
}
/**
* Application init()
*/
public function main(){
var mc:Alert = Alert.show("Demo application using gettext for internationalization (i18n) puropose. Press the 'OK' button to load the English default language, then use the combo for switch between languages", "Flash and gettext", Alert.OK, this, null, null, Alert.OK);
mc.addEventListener("click", this.handleEvent);
}
/**
* shortcut usually used for
* gettext applications
*/
public function _(name:String):String
{
return gettext.translate(name);
}
public function log(text:String)
{
logger.text += text + "\n"
logger.vPosition = logger.maxVPosition
}
public function handleError(event:ErrorEvent)
{
log(event.text);
}
public function get_url()
{
navigateToURL(new URLRequest('http://www.gnu.org/software/gettext/'));
}
public function init_app():Void
{
Alert.show("Titolo", "testo", Alert.OK, this, null, null, Alert.OK);
}
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Canvas width="100%" height="100%"&gt;
&lt;mx:Label x="29" y="20" text="Gettext application demo" fontFamily="Georgia" fontWeight="bold" fontSize="18"/&gt;
&lt;mx:HRule x="33" y="39" width="560" height="20" themeColor="haloBlue"/&gt;
&lt;mx:HRule x="33" y="195" width="560" height="20" themeColor="haloBlue"/&gt;
&lt;mx:HRule x="33" y="89" width="560" height="20" themeColor="haloBlue"/&gt;
&lt;mx:Label x="32" y="111" text="log:" width="133"/&gt;
&lt;mx:Link x="369" y="26" label="http://www.gnu.org/software/gettext/" width="226" themeColor="haloBlue" textAlign="right" click="get_url()" toolTip="{_('Visit the GNU gettext project')}"/&gt;
&lt;mx:TextArea x="32" y="137" width="560" height="59" id="logger" editable="false" wordWrap="true"/&gt;
&lt;mx:HBox x="35" y="54" width="560" height="38" id="h_box_1" horizontalAlign="left" verticalAlign="middle" label="combo box languages"&gt;
&lt;/mx:HBox&gt;
&lt;mx:VBox id="v_box_1" horizontalAlign="left" verticalAlign="top" height="362" y="217"&gt;
&lt;mx:layoutConstraints&gt;
&lt;mx:EdgeAnchor right="243" left="33"/&gt;
&lt;/mx:layoutConstraints&gt;
&lt;/mx:VBox&gt;
&lt;/mx:Canvas&gt;
&lt;/mx:Application&gt;</pre>
<p><a href="http://code.google.com/p/sepy-gettext/">http://code.google.com/p/sepy-gettext/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2005/12/06/actionscript-3-0-first-attempt/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
