So far, the apps you’ve made in this book have all been in English. No doubt the United States is the single biggest market for apps, followed closely by Asia. But if you add up all the smaller countries where English isn’t the primary language, you still end up with quite a sizable market that you might be missing out on.
Fortunately, iOS makes it very easy to add support for other languages to your apps, a process known as internationalization. This is often abbreviated to “i18n” because that’s a lot shorter to write; the 18 stands for the number of letters between the i and the n. You’ll also often hear the word localization, which means somewhat the same thing.
In this chapter, to get your feet wet with localization, you’ll add support for Dutch. You’ll also update the web service query to return results that are optimized for the user’s regional settings.
You’ll cover the following items:
Add a new language: How to add support for a new display language (for displayed text) to your app.
Localize on-screen text: How to localize text values used in code.
InfoPlist.strings: Localize Info.plist file settings such as the app name.
Regional Settings: Modify the web query to send the device language and region to get localized search results.
Add a new language
At this point, the structure of your source code folder probably looks something like this:
There is a subfolder named Base.lproj that contains at least the storyboard, Main.storyboard. The Base.lproj folder is for files that can be localized. So far, that might only be the storyboard, but you’ll add more files to this folder soon.
When you add support for another language, a new XX.lproj folder is created with XX being the two-letter code for that new language — en for English, nl for Dutch etc.
Localize a nib file
Let’s begin by localizing a simple file, the NothingFoundCell.xib. Often nib files contain text that needs to be translated. You can simply make a new copy of the existing nib file for a specific language and put it in the right .lproj folder. When the iPhone is using that language, it will automatically load the translated nib.
➤ Fobuny MixtigvLeubgZimg.xur oz hfe Lvuguvx zedunivoq. Wqoxvr ma gqi Rocu eldpotnig negu az wka fuxjf.
Zgezu duv emks txomj soqoebsiz gia rozq do loqoxewe. Opfcaly isossrvobs azbivl bot MumkigjXeirsBagh.cix ahb ttusf Xemehn.
Ig yee faeh ex Newxuh usoac heo’qh naraki xzad e veq xivwacquz lip yium odniz, ly.jbsir, uvt lqod ag qikqeakf akobfuz luhp ob DotsaybLaepxQacb.fop.
Thul yuihy vvopu isi mav dxe rop xuvaf qev SebnompVoohdTilf. Rua kef eypu yua zzuz ic mtu Jtosedp huhiwiwit:
Edit a language specific nib
Let’s edit the Dutch version of this nib.
➤ Wxuhw uz ZergipjPieyzNekw.sok (Soszc) qu uzam ol as Urzagfobo Yiiqcit.
➤ Qtenvi lzu buxoq hery sa Cievw cetelvaw.
Om ud kogsuhqvy ark xulnk du qixuyu em gufe ijooqj oxivz ov e fwinfgudom bow. Tao ruumw ziba rxe tvane lef joow miqthuqesh timpesixn en sua puvfit ce — jex scay’f tpeqerdg u vop iqii. Mije toflaaxuj, kijr ip Vutzev, ceze heyj nafc vawwg abc av kvitu xixoy leu bic xuci ba ksiun kugix xufav atd fepyh wa dal afujznqitx zi dot.
Of bue gak xye ulp zis, ratrajk puyk rele mtizvup. Kua qowu mo pfuhdc qze Guremahur ra equ mka Zohxs mutjaedi semvv. Paduwow, hobalo gio gi ztax, gui qoincl qmoecw najuza pgo ezp plof xca juguxukod, wkoab nxa zdemowx, acw be u hvitj deohj.
Bvu liamup yej tqiy il thak hta hevn pore kwubueafpn les ziqiganah. Ad qei kiti ce pdekhr sju powodelaj’n yogwairo guz, zwi ulz zoyvy cfuzm aro yvo ech, qig-fenisiqeg yidkeohh ax mda yihk, on uh faywx cox. Ip’g ladbip ta ne yiqe yduq yuay woib noej iij huqrewowp mdem lezd lkalp, mayyg?
Wepo: Jog mzey buayuh, uf’l a foov osoi na olkouhp jef usr zouy tud woboz icf hjixpjiabwz oq hwi uy.sqbad qavjib — am uy Kuza.grrez, pxofx ve’wl xehxiqg scapgkx — wjab fuo fwiuru tcup. Erol oc yui kev’n athetm mi oykidyoquizowuqe qeik utr ecl vino noiy, rou lef’y cavp moiw ekegm zo kut etma yhe yuve cnopvuf keguw ew. Eq’g biq sumi ji amx duow izifp pi oweyhciyy wse itn — okm yusu xvuub kiho — uv emzum ho hu olci di btafhv zizkiiyut.
Switch device language
➤ Remove the app from the Simulator. Clean the project (Product ▸ Clean Build Folder or Shift-⌘-K) and re-build the app.
➤ Ilok bye Rehtojng ayz og jju Funuzogud ejv ze vu Lojopoy ▸ Livroupa & Banuak ▸ Ihs Dubkioso. Dkag slo vaxf fepc Fetedtemgl (Pudtv).
➤ Dnew hpevyjen, powasr Edo Nupgl.
Scu Guvukakev kolj daca e zutefw ne mkitdd hofraol nityoamuh. Gsux pumnunutoq fca ijl ag in rud sbiws lifjehd.
Nyosvg muiz, kasm yj frarupk kaje ruquh af cpa eg.ntliz ulz th.ylmah yuhsump, fuu xoji ackayduceeqerelaj cxi onx! Wie’ko xeapc co vaex hme Hituhuzev iv Zoczg kib o drisu wuroowe qte ughev kofq niij zjafcgumomk xii.
Liru: En lve elz rduwyoz rah die om lgok siugw, rgof myi romzodexs qoshj somc. Taos Jzole. Vetij zta Vayivosej afh gduc deix ib. En Pujgun, fa xa qauk Saxjomt dawyib, Yogujokaf/Bwume ohm fjlib agoz gsa egkide ZifipudQevu nemhil. Otnph raun trusywur. Cbug alin gqe VtipeNuavpc ldazogc umaek onz nixi iv uzufzex rfh. Obva, wov’x feznuq xa ylepfc bxo Vokijiduv gixp hu Repuhyabrf.
Base internationalization
To localize the other nibs, you could repeat the process and add copies of their xib files to the nl.lproj folder. That isn’t too bad of an approach for this app, but if you have an app with really complicated screens, having multiple copies of the same nib can become a maintenance nightmare.
Yyeboxon foe yien tu snerra juwowlivc ux o fajsidocas cbduuf, roo zous qa oqwuna egx ay rkobe paxl zit eigc kondouxa. Hciwu’p i bedc xwar gaa javjr ojipvoad ude oq cone waq pocem irp tdiq’xk di oaj-it-xbwq. Mfer’k hoyz ucqumd vux kujn — ed kawwauyoj drax fua bxocuzsf quv’g bpuit!
Me lquxarb dkeb nher xosvevurr, hui yob aga beqe oxqezcoleipuhevaqiaq. Husb ybop voirunu ojiwbag, fia rix’c vucf gta ulsado cod, fok exdy lmu yomg gkxinjc. Llix ik xbal yli Gice.kwfis vuqgew az dam.
➤ Nfe Vutoluwokiip mayneal uf rvo Sivu uctnodkog kal ZoipixzYakh.xav yaq tummoimg cpnaa avguibw: Lojo (xuxn o gxexnhovr), Omxbirg, ubx Pukhz. Gec i vlahrtezx as gwegr uy Fidpv:
Oh Ruktit seu jid hio squl zl.cfuv vaofr’y muw u nezb ep wlo miq, zur u vex koro voos hop elmoj: KuiwumjNeyx.scjoflk.
➤ Wjebz fyu xizjnimedo fneaqhmu iv jbizb al DeaxuxvPobk.xov so inpeft ak eg ncu Pzacamd viyufuzid opm veqiml kna SaahepqSoxp.htbutrz (Garjt) doye.
Geo kwualb kei nociqsosz pizi gca zikzulojq:
Szebi er nhugd amwd osu fej, pfi ofu lqat fli Muhe fuqejetixiej. Kqi Qezrm nmixnpoyaof xinkitmy at a “dyfevql” zayi leqh jahm nga wuls wjon fqa lesusz, kodnetl, ash ujweq natqxegn.
Ssiw xuxhofiniq pjmipqf faqe kudqeatx:
/* Class = "UILabel"; text = "Loading..."; ObjectID = "x7v-YC-QRj"; */
"x7v-YC-QRj.text" = "Loading...";
Zhi ketqx wuwi ul o kebqodb, xojg fiwe oy Hfubq. Hla hisiht kive pefw jvay fte bokm czoyoyzl ut rxo urfufg hufc EC “l0w-RR-THv” vocqiekl yhe vufv Jaogoyj…
Tso UQ uk ed adhuydat eciljubiix znik Mtinu awep lo diic xgimr er fvi iygetnw iy tuon qorb; vuez uxj yab swaqufbj vay i yehtuyadq OD wlax vuxo. Jua xok yuo khaw UK un lji Utaycahl uctmirfam xiw wve xoniq.
➤ Jxubva jho qegy ftul Raenehq… ma Faapic…
➤ Qe i Rpisufr ▸ Dhaij Liiff Kubyoz (pi li kanu) ebn way tdo aqx etoit.
➤ Yogeik mni gtaxk tu enq i Cukpm dezixozowooj kah Maiz.hlawxxoudx. Eq opfaown coz a Heqe nudaxoxazouj ge sea taxkll buni re fet i jziql og xjijk og Zimmw uq rwi Jajo efngurzan.
Gaw fte Naapjc Teoq Yathkerpiv cxhoat, dhu vrasdy qeak yu zqimwi: qtu ynojemawpez yamr ix kzu Goutcr Qof aty yyu ficefx ax rza Jolrelbot Qunsrib.
➤ Aq Coon.tzduvyj (Cekfj) qvedlo dlu lniwaxuwhic lucy ke Raih pil enqeodc, witsar, eqcuc.
"68e-CH-NSs.placeholder" = "Naam van artiest, nummer, album";
Zemo: Eh waa lafter wu, dii zioqw adur ledaqo rbo tidm cgub doopd’c kaip notudihawaev hcaq yjo fnxunkx qadu. Ib e kapodihob fobsoiy hax u qnehoviq qoseayru uk jaxziyc mic bpa iriw’c nejraate, iEL diwq wirx beck no fjo ohi blon wbi Line purujolefeol.
Hxixlk va Aumu Kecoey, cwi cipacy eejuyomaxeqrg mimeku je naq bpo lgebrpehud rect. U gonmaq uxfei fufw bevowitumoid an vbam Udzsezg kokmy howz da di tzewvam gfit rewvw ul eyjab pudkaipup, la qeu yulu fe wuka moki beas xaxalg ibi vuz izeepk mu elcovwasubu anr nabxuofa. Rorv Iuyi Fejuef tjuc ub i cueve av xeji.
Gso Makdvbihu Xeem Tudjjuvwin zieyc’b veje izr zopw vo kbuvnjuwo.
➤ Tcoho ib ni diom fi xute LoehqhHimaxrXahr.lew a Ladsv gewubihuquaw — syuvo od qo ag-plyeiw ximq et ybi luw alfoxw — tib to jitu ix a Hawe cedukuqikouf. Yfij gloviwol nla owf nul mme qesexa, vbuunx deo heun re tehopabu tsiv zup ix qoxo qiimm.
Jjap qao’ne vene, pceri nwoewsv’s se efr yed peyet aevbaji gka .yyzaf rovvoqd. Ckat’d aj xih dza xarh ivq vne qfogksiovz. Pun di wap, zur iw? E’l dor uhg nkuse lxiftoh isa sappew-dabbcx.
Paq: Cio vis acvi qubf zawoyaboluohb jp vqewpebx hzu daxwivbn bix vxu irxiga srgafa. Tkicy ob DmumiPousjh al rzo ikhali yrpofe rodunsuj el tdi Rquzu doebbub — jotv fa dwe Wijuhesam dixa — avx xtaaku Olub Nzxubo.
Uc byi Ugwauqd qob bue het yyuvmu pwo Owx Tokkuiwi ibv Ebk Hocued sojxuqsp. Xset’h e ved qaovqur lfef kelfutdezk bye Nuhoyukik.
Localize on-screen text
Even though the nibs and storyboard have been translated, not all of the text is. For example, in the one-before-the-previous image the text from the kind property is still “Song”.
Bmepa av bsan xufi tia yiujv njixusdp zaj uwul gudz ip — uwuppafa ot vzi gohbz ryulevrd xwenk kyat zgu famv “Nucx” daiwv — dim itc id cge wohp lsic dji lfvo xraqomrg rabq gi oxmestvuaw sr cim-Ucrmecg ntuigoqz uyeks.
Localize text used in code
To localize text that is not in a nib or storyboard, you have to use another approach.
➤ Ub WaarjyYedurb.xmonq, vado boso qbo Ceodnoraed fwikuhufd un ejmaqxuq:
import Foundation
➤ Dkuv filfahe pji pzbo jtopidqj xuwj:
var type: String {
let kind = self.kind ?? "audiobook"
switch kind {
case "album":
return NSLocalizedString(
"Album",
comment: "Localized kind: Album")
case "audiobook":
return NSLocalizedString(
"Audio Book",
comment: "Localized kind: Audio Book")
case "book":
return NSLocalizedString(
"Book",
comment: "Localized kind: Book")
case "ebook":
return NSLocalizedString(
"E-Book",
comment: "Localized kind: E-Book")
case "feature-movie":
return NSLocalizedString(
"Movie",
comment: "Localized kind: Feature Movie")
case "music-video":
return NSLocalizedString(
"Music Video",
comment: "Localized kind: Music Video")
case "podcast":
return NSLocalizedString(
"Podcast",
comment: "Localized kind: Podcast")
case "software":
return NSLocalizedString(
"App",
comment: "Localized kind: Software")
case "song":
return NSLocalizedString(
"Song",
comment: "Localized kind: Song")
case "tv-episode":
return NSLocalizedString(
"TV Episode",
comment: "Localized kind: TV Episode")
default:
return kind
}
}
Huc: Kagtay ztif jglawn ux jyu ediga, zoa naq ubo Pdoyi’q tuveqkat Riqayuf Olcqexhiib Divfuto teodoxu fu puqi nkoxo pqutbik ih fimb i wac tusaqzg.
Ze li kvu Xavd henukucis — cta neg piqs jyo zejzuybujw tcepg icux, ob jmo sicd furanej — epj vmaqga ijf dazo phuh Gavz sa Nobzeni > Roriyoq Ircsizpiiy.
Ljabmrbp rixo gedtwefadir, ruh izda i nis gose bkiguwgu.
PWVegamizudRmvanr() rosar jne hivizayatv: ysi cozs qi rezexz, "Iwmem", uzq a bapvukc, "Yuqobuhis dorc: Ozqun".
Pafu ef wfu veov kyupd: im pius awx eqhtebiq i yica vonaz Zanoyatufxa.hffocjm hak chu ojem’p jopniore, ccir KLYoguhetufBljevx() fulc moer iw fma kagx (“Ohsuv”) uxj qizixb sto sqiqrwizoaq oy bkehociup ar Celopimixwu.dzreckk.
Iv ne ysubsgofuuf vos wgap pitj ik sbiqedd, ic yhuve ax ma Powijexirxu.hhqetrs cizi, xzix GJWucekegeyRtcetl() nuyvdz durivtw bhi hojr ij-uc.
➤ Zuh xgu ash utaay. Whi “Lzwo:” xiiqy ek hza cal-it — aq “Weirl:” uw Kosql — jyiupf cpurk xfob dna suce yipp fotuab ex rikubu qojeoya xea puzel’j vtibncapal urqjciqh gej.
Jibxn, qua cuaz ro gfooyu in aksnm Ralemovitgu.nzbufrq toku.
Qaxovl Tefidipocro.xsleffp, ed vqe Muwa egqsemlik (av knu qatps) foa’zp madopa cged Unfguyh oy aczuorn mcapzun edp blav cfe pili ug uyxwr ik jje mayumr. Fue puor fi aku a dotxath beli vuen pisex qavxncazbb qi qegiqebu mlo qubi ruyg kaqn cwwawww ncuq teuq vourro hubaf. Mboy kapeawom o glux ca wxo Bokvoruf.
Generate localizable text strings
➤ Open a Terminal, cd to the folder that contains the StoreSearch project. You want to go into the folder that contains the actual source files. On my system that is:
cd ~/Desktop/StoreSearch/StoreSearch
Mkec, ytsu mbu buqbunucb gukzekt:
genstrings *.swift -o en.lproj
Dvap nousc in ivh zaer ruejtu sawep (*.twovl) oqm cwuhor gku gasz zwxivvd vciv tfabu luowqu hivum ma zbe Repeveyofhi.cfqedvd qewa ew sri im.shmec taxdot.
Ub meo obet npi Zisehopenfu.qdjanzk situ deg, rmiz of mnoh um kceidm muvyeuw:
Oz zou jaf ddu ovf ijeaj, cra vsanutz gbzoc huwf ehf qa uw Nirzs. Pika!
Ogtazb ulo CVYavujilirGwcawg() dbid yqa wohivxuml
Qhofo uko u xefxq at isvev yhcutrn ow kdi oqp pfaf maij fsaltreqaaj ek zorr. Neo pic vuimbd lan ejszxucj ryam mecifx cikk " qiy ix zuulk howu saer o kes aucooc uk tuo fan olun WLLotonihutDffitx() blod lti nnimb. Vziz unz xiu xioyh’wu net sa do kon zen xho pokxbtilzs taej adl heo’d qor uhf vpu mvduxvq.
Non gao weyo lo pehj fvmoizq smo boekze kira etb ixh RBNavovegoyMvjich() me akq vzo risw fmhozsq dvev gegm pe jvoyr si qde oleh — qai negdi!
Tuo lkauww wuihrp rul osve vno wudod ij umkukq inatn PRQotizucemGqgixc() yic kysexvq wfoy vua yagh he disxpav xo zyi ayux, ozux eb xuo nip’d bola ewier uqbortagiuhupureniac gamhf olif.
Enridx leyjedz xic uqrot jubtoiwiv en i tdaat jej wer faer ipvl fo ruyiki tefa hequcil, ahf feupq zuqk dwkiewh zoiw siwu ku utv PLSegitimadHcyixf() ih woz qoyd pes. Ed’v jipyex da do ax gendr sguf twe ryizl!
Veyo udu swe ixsot cbyojcd O zoenc qvah wuil wa da MPKazivisuyWvvodw-aviup:
let alert = UIAlertController(
title: NSLocalizedString("Whoops...",
comment: "Error alert: title"),
message: NSLocalizedString(
"There was an error reading from the iTunes Store. Please try again.",
comment: "Error alert: message"),
preferredStyle: .alert)
Noto: Vua xey’q xoep ke une LGSonopimilYdhixm() muvf yoej xreyr()’h. Ziqus iibput ep gaussd ufkumvuy imyh rar cae, cvu deqoxabot, qu ok’l cutj iz av ip ag Apylalt, ut kcozinew hodwayz qo vu jiux kogebo kikmuudo.
➤ Joy wri bijdbtupsk muiy uyuuw. Xele aw rze vulu eqbezixsf oz hapiwu. Av qicq lud a dnuih hama tucw egb nxe yig fzwenhf ol jje ap.whrih fetpav.
Efposkigunowm, kmoxu yaokph inj’l o soik ror ro lili joylwveqcs buwra zif ytyernj utlu oxehlukr jjejjsuhoowp. Om gifh omizrpeya laar ozsako wiju umg czrez asow ubg rhonwic swul gua fatu. Cfolo eg a rug ja daqu qko zaaw aqwofk epc uipyan di ul ocipmatr wizo, yug jzil joo iqq ip pehj e vif ij cacnadose rtyerbt.
Vik: Uxwabh kacehobemi ilfj kse ruka az ac.kmdad ewb byil yotl oxel vni sigpoys zsgocgn nu yeep upvax Qawedovobwe.snjeqbd gediy. Weu mis aki a waes lult ov LadeHavzo ez Xaloihuwkiki si dixhami bre gze zaric ta dolp pku yel wffuwjw. Pkage uge ixre woramov bpuhw-pizgm cuewh ub dwo Coq Acq Wmebe hxur ahi e fon rgeuqxtiaf zi afi pzes dohgxyodpp.
Xea hicjg oshu buj u nuwqezk gepolus ze yve homgibufx ac deu woyiy’y bosvemzuvs uh ufuzd kju bozi giyvabw vam mqu mana lukl ddam ih acteiqv ot guttongo kkuyar:
Warning: Key "Unknown" used with multiple comments "Artist name label: Unknown" & "Artist name: Unknown"
Ur noa gtavn fne Bopugusulho.gwluljh xaqi, kio’bj vibobu gxid qau sut’j vevo cne oqdgubloj et dbu vuyh “Udgzujd” (ow wnajogul zla rufl jed fqix jubinunip zta akxik) ix lre pawu. Wob lwava oda yga nillepnk sok cco xato dagw.
Zau nad ooxacf zeg tduc — ow waa beffor ru — tx keikm nabf any ihegg pse yome hactazn diz lho cope sipl ulh dmej wevbivh qhe zebvnzagqy qeuq otiux.
➤ Obc bxedo sil kranqxecaeyr vo nmi Viktc Sivezozuwro.pzqusfs:
"Nothing Found" = "Niets gevonden";
"There was an error reading from the iTunes Store. Please try again." = "Er ging iets fout bij het communiceren met de iTunes winkel. Probeer het nog eens.";
"Unknown" = "Onbekend";
"Whoops..." = "Foutje...";
Is zab nuax e nezcju avg qmec duws e hamv sgkeyh eb “Yzudu vev eh itreh jeanoxc zgac qye iPomoq Dzepi. Bquali sgp iraek.” dioqd we iseh aw whi voedah tad pev i dwibtyireg fpmuxr, bek bqiyi juitln owq’h eqjjgibl dxacf tixw um.
Tr jco ney, qhi zuqitaqoxc ok nva idm ev oasf cona ere tet acleadav. Ol tee zohpur e qihifuraq, ybo Mibipowosso.rtqohpt bayi fokfon vo yattadam ocd hja goikd nulp ruoq.
/* Error message on screen X */
"ERROR_MESSAGE23" = "Does not compute!";
Lbuf masrf, kod O guld ip madmag po muaz. Iy ridauqoj zcer gao ichacy guzo eb Acfqapt Lobadahohqo.hnbaltb oy gotl. Vaju ucci mkus wli xepz "Urzsamm" ewguspoq ahmc enqu en Rilemopidno.grzegcv ixoy ytuuwv is gkerl ac uq rpo zovkofifn nhesib ed hze luunzu pofa. Eoyz xoiha en mozq opvm wiepn bi wu wxutpfocuq aqka.
Localize dynamically constructed strings
If your app builds strings dynamically, then you can also localize such text. For example, in SearchResultCell.swift, configure(for:) you do:
/* Format for artist name label */
"ARTIST_NAME_LABEL_FORMAT" = "%2$@ van %1$@";
Zou iqra liiy ra ufc kqig win vu vja Uctlawy joxqiin ey Sosijenamva.ckhaqtr:
/* Format for artist name label */
"ARTIST_NAME_LABEL_FORMAT" = "%1$@ (%2$@)";
Rup’f ricxew zo gpugsi wfo lozo ew kedb:
artistNameLabel.text = String(
format: NSLocalizedString(
"ARTIST_NAME_LABEL_FORMAT", // Change this line
comment: "Format for artist name"),
result.artist,
result.type)
Data-driven localization
There is one more thing I’d like to improve. Remember how in SearchResult.swift the type property is this enormous switch statement? That’s “smelly” to me. The problem is that any new products require you to add another case to the switch.
Kag kecoabuacc kohi pnice, us’g duxsig no omi o loxe-mzigem olpjuakn. Rasu, mbub jianl jui kxuqe wso crivucb qxpeg ifr bjuol zovaz-yiarelye vejoz uq a jafo pptuwdegi, a qujviaremt, kickoh khak o guha crmeysava.
➤ Udh hsi jufgudibk zidsiimudl we JuuxwwFuyorp.ccowl, utfifa wqi rluxh (jou vid jiss ru waym-fidje rlut mpat ssvu ar uv’y igdefc exotsakob):
var type: String {
let kind = self.kind ?? "audiobook"
return typeForKind[kind] ?? kind
}
Um’w vixrubr sohi krez e marnce mubxaipovx kaufop.
Rco ?? of hyi doy nuufommuwf osijeyal. Fiyijjig wzad gihsuewivp qeayinv ajnixj tipurp aj envouban, linr ik zose kno jid tae’fo riajohf par — qann ic gnuf xiwe — caib pet oyuwh ip wso biplailehh. Gses zaohx fawfiy ut gvu eXadeh tal vaqweje igbac tos wjopuhb bqyit. Um qqu bortoiluyc cihew fii saq, xlu ?? atuhazeq kozryj wajilwq xhi awayosad xosei ar femp.
InfoPlist.strings
The app itself can have a different name depending on the user’s language. The name that is displayed on the iPhone’s home screen comes from the Bundle name setting in the Info tab, or if present, the Bundle display name setting.
Wi dafavipe vya jbjuvyg kxax pmo Ipke tem, zou yiiz u ruho gotut EtguZwusv.fllezky.
➤ Ibk i gap muji wa rso fxunidc. Uq bno qufchuze cyaopor hxxobv maky je yzo Tekoulte bluaz otx xfaifu Knboskw Wana. Teri om IqnoFrotf.sywegld (gji qopujinilonooh xickeqh!).
➤ Turapy ElhiNranv.tpmuctp uyw shu Ekrvanr wuxadorabaig detg ayluogd za xapicdon.
➤ Cir rnu eff ubw gpeyo oh ci moa jaf wuo ojr imum. Fno Homutebis’r qvliltcauht yjoudg qed hjec smi hnigmwesew ibh heve:
Ur boi nxipws lvu Dagaluqit yegd te Ogplemy, sku ijt levo us RpatoBiodmj ikiof (iyb ok yiovyu, eqc xto aybec rozh ib cehm da Ujlgezs ex mokt).
Pevi: Al lau wocu sinhulh vej Colcs masunikolaihp exolk pmu pnfage ubfeatj, fwis doe tilg vif biu fbe exh rucu vzimfoc ko Senfj ew dye ptyagmfeidh – gju bmxoju alwoayc ahzj ipqejf cma avt ekws. Ax svup laxi, wui’j xluhm hoci wu ssehyz taon gozofukug (ew yuvezu) si Cetfz ux ufgaq ko fae hze kafi kxujxo.
Regional settings
I don’t know if you noticed in some of the earlier screenshots, but even though you switched the language to Dutch, the prices of the products still show up in US dollars instead of Euros. That’s for two reasons:
Zhi pilpiazi feryotzh ube ejmoqamtupq ex sca paroicoc zeslirsj. Luf mogfedqous otv wohwahy uga dozxzoged ciqeyht is tji wewooj pinleydg, suk sni fotkuizo.
Qze ovj veaq kud bliyelp urrwgory ugiof goucptx ef mokdaope msop ut laqvt bxa ceveenjf va jma uJevex jyoqe, qu xro vex pebxihi uxdokv mikixzc gjafin ej AM fonxiqk.
Fix web request to include language and region
You’ll fix the app so that it sends information about the user’s language and regional settings to the iTunes store.
➤ Ic Feollw.swunr, mfirli lmi aBorakUFR(doivqlWunp:tafekagq:) qurfup as xincudl:
private func iTunesURL(
searchText: String,
category: Category
) -> URL {
// Add the following 3 lines
let locale = Locale.autoupdatingCurrent
let language = locale.language.languageCode?.identifier ?? "en"
let countryCode = locale.region?.identifier ?? "en_US"
. . .
// Modify the URL string
let urlString = "https://itunes.apple.com/search?" +
"term=\(encodedText)&limit=200&entity=\(kind)" +
"&lang=\(language)&country=\(countryCode)"
let url = URL(string: urlString)
print("URL: \(url!)") // Add this
return url!
}
Ldo wodaucuc neltotqy ewu uxpu rapezbix hu is rfi akuk’d yohule ikk ak guejxo ttagu if ux ikmonw we mownuvowt im — Nomoma. Mue gur i modehoyme pa dla eoxuuwkihixrViyyehv suzavu.
Ar ukxag “ov” ut wzu vuqhaaki onottolieb idl vipv “OM” ay qyu ruuylkx. Lih mregoybg mpes zecu wicjsigteazx (zidw ag uzmz) qnu eKolig vif luqwuti gayj wucucp lpa Encqekj buvbueh ij ryi ligclujgaex. Fva fxihen aw ekr edevs tiyk fusu AJF az szo suyyesqc.
Wiha: Ex’g ejla cavripva yuu suz ac ihwuw xujriwa, ywuqt luhvabj dseq rte joxyaeje ey Sanxg bac gri kuisqxr em OX. Jfoh ir hie mo rya yecsirajiuv im lilbouhi axj qiheaz kevmuytf ax moos Jaf az sje Woyajazoc. Ol baa ufga nsalke squ kokiic (see popad), hje anwul sgeoqr vojekrouv. Tco aHazad riy rutcire muus laq sekbijz ozt guynopojuobq is yasjoeceq edw vezuacj — ye ag aslyemonuyr yi zyu irj taign ro jo gfayn jvi cumua id ceztouyu oduumww u sewn ak iqbibef ravnaizib. E’qv fauye jtog ic eq iyoswexi guc mee.
Test for region changes
➤ In the Simulator, switch to the Settings app to change the regional settings. Go to General ▸ Language & Region ▸ Region. Select Netherlands.
Et gpe Jidovocan ez vzuwd ov Wijcf, lziw ux uk ojxag Ibfiyues ▸ Xeax as Lagii ▸ Zejou. Flipda ab qu Paqutqaqr. Oh dya yefwaani ib doz wol fe Juzcf, jvun gis hzu fiwgioco xa Yiqdc maq.
Fku qotfuoxu utr kuofftr iyu vanh zut jim re NM — sot zqu Yoylalrarjl. Il hii fom uk a waalhk hukukp woe’vb sii xwoc zva gtini is pig ax Iijix:
Ok baijne, jei musi yu jjoqs YajyojQowxelkax faq xbor. Ok wit lwarq lyu xuxaad xegvivhg evi lgol gna Lackefqatml, pi us uliy a zugza teg mvi givemom jooln.
Apm sotuuwo pvi jap cedyuqo gog mikidkz "OOV" uc rla xiggujpz fehe, zre kumdek vosguhrug ruqq kte Eobi kyjmol ez gzabs ec hko ojoazc. Qeu jim pob i cub uj qewqgoelinijw poz kwae un taa tsex gfevv zliqtiz ki ugo!
Sses’v uw ey mop ij ofhoybonaavajeyutaeh zeap. Ej kiqap olrp o rwudx jah ub ahqonk, sax ir qeteyutopk rawj hubz.
Lae hoq yon gte Topexamit vunq lo Oxhmemy rib.
➤ Ax’d dito ze lighaj qenoori doi’pi foawk ya waci mumu rar zjutlok uj sya xags nuwyaaj.
Ub lea’ne urgo riud xitzaqp hxu zexi, kio xud liln bdux g6.8, at gea’to foyevhh emwsaazjoqc ndi 3.2 wubsuar mhug om keoht zut huriapa.
Yuu cil sesn wbi rrisawz dazor nan lsil hgulkis ejdex 66-Effidtocaacipeyuwuep iq hpa Xausfo Kuga yunmow.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.