<?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>Learning the Ropes &#187; localization</title>
	<atom:link href="http://davidmiller.serafinistudios.com/tag/localization/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidmiller.serafinistudios.com</link>
	<description>David&#039;s experiences interning with Serafini Studios</description>
	<lastBuildDate>Sat, 04 Dec 2010 04:17:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>On Monday, I spent some time in the morn&#8230;</title>
		<link>http://davidmiller.serafinistudios.com/2009/07/on-monday-i-spent-some-time-in-the-morn/</link>
		<comments>http://davidmiller.serafinistudios.com/2009/07/on-monday-i-spent-some-time-in-the-morn/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 00:09:57 +0000</pubDate>
		<dc:creator>intern</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cheapest]]></category>
		<category><![CDATA[decimal separators]]></category>
		<category><![CDATA[iPhone development]]></category>
		<category><![CDATA[localization]]></category>

		<guid isPermaLink="false">http://davidmiller.serafinistudios.com/2009/07/01/on-monday-i-spent-some-time-in-the-morn/</guid>
		<description><![CDATA[On Monday, I spent some time in the morning polishing up the photoshop comps I&#8217;d been working on. There&#8217;ll be a more detailed full writeup on the process I went through with those once they&#8217;re totally finished. In the afternoon I turned my attentions back to the Cheapest app. My mission: to locate and fix [...]]]></description>
			<content:encoded><![CDATA[<p>On Monday, I spent some time in the morning polishing up the photoshop comps I&#8217;d been working on. There&#8217;ll be a more detailed full writeup on the process I went through with those once they&#8217;re totally finished. In the afternoon I turned my attentions back to the <a href="http://katanaa.com/iphone-apps/cheapest/">Cheapest app</a>. My mission: to locate and fix a bug that prevented use of numbers after the decimal point when an iPhone&#8217;s localization settings dictate a comma instead of a period as the decimal separator.</p>
<p>There was already some cleverness going on in terms of localization: the following line of code made sure that where appropriate, the comma was used instead of the period:<br />
<code>decimalChar = field.formatter.decimalSeparator;</code><br />
<code>decimalChar</code> is then appended to the current digits in the field. This is all well and good: people get a familiar decimal separator. The problem was that when they moved on to the next field, digits after the decimal were lost.</p>
<p>What a mystery. I should mention that these are really my first forays into objective-c, so I&#8217;m very much learning to read the syntax as I go. After some time spent reading documentation, and hunting through different parts of the program, including an introduction by Steve to the debugging features in x-code, I figured out the process the application went through each time a field lost focus.</p>
<p>When the user presses a key on the calculator keyboard built into the app, that digit is appended to a string variable (string of text). Only when the field loses focus, is that value mined for its numbers, and passed to a different variable in the local currency format. The problem was, the part of the program that stripped the numbers out of the text didn&#8217;t know what to do with a comma, and so digits after the comma were lost.</p>
<p>The fix was quite simple: change commas to periods, before parsing the string for its numbers. I didn&#8217;t need to worry about putting commas back in, because the currency-formatted variable that reads those numbers already knows about localisation.</p>
<p>So the problem was fixed with a single line of code, incidentally, my very first line of code to go into a published application.</p>
<p>And here it is:<br />
<code>title = [title stringByReplacingOccurrencesOfString:@"," withString:@"."];</code></p>
<p>Takehome lessons:</p>
<ol>
<li><code>doubleValue</code> doesn&#8217;t know about commas or localisation</li>
<li>x-code&#8217;s documentation feature is my friend</li>
<li>spend time figuring out exactly where your bug is happening in the code</li>
<li>use debugging tools to do this</li>
<li>once you know where it&#8217;s all going wrong, the hard part might well be over</li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://davidmiller.serafinistudios.com/2009/07/on-monday-i-spent-some-time-in-the-morn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

