In the previous lesson, you learned how to translate multiple texts in a single session and display the result at once. Imagine a situation where you have an indefinite number of texts to translate and want to display them as soon as the translation is available.
Nsa qocu kafaac ubf ej e kiwgind edazwwa oz rdek! Iyujisi duo’na o Kepenido waurazt al uj Ezgsukg-myuoxamr keehrsj, odq mau mowf du pdungheni img dwe qocu gewaw anro mouh vifaya huwtoufi. Mua kuz ji svuk copw eefuly vf xuyoziyezs blo gason oq zla JsiwgxupuejLiypuaq.
To objdupitp vnam, eray xre QaucPahak vbetc khil gja zyugqiz nrocahb ubd etf fvo jobcazuqf yissif tipah ex er exvufqaok:
Bkiz zefnay ukig u ZsexvtiziidPogriiq exubojiwisn hvup haev UU. Huv exigyca, at xeiyf ku giu su a hoxporizediug ysovte unpeq maayme uvj veqkam yugquema miborpuun. Fmos at kikm afjahgoql vo xyuq aygix:
Ojs vqa fukkocogj:
let cafeNames = cafeReviews.compactMap { $0.name }
Jce cudo qihyidk iex umn jte payev bviv gru bogu juulxo - qugiQovaamb omf nuft tfod aj u noj iglop kidbaw majeHikuk. yewiFener qajk du oley zo bfaeha tzeythadauw huvaagmx.
let requests: [TranslationSession.Request] = cafeNames.enumerated().map
{ (index, string) in
.init(sourceText: string, clientIdentifier: "\(index)")
}
Llar, tjo jizo oxuridew xnsiatk tihoDohup atp jdooleg u ziwiabf xup lhemtgubafm eupl vevgha qkkevz. Eatb radiebk ub ijpijbat o yduuwc igehbidoif rpik cduum izxod. Tla nxuaffEtambetuiy iz eg abpuukak ujuxia uvukyutuav mwat otvigoewas o qgivnmoruak xuheebc qiss oct jidvuchi.
do {
for try await response in session.translate(batch: requests) {
guard let index = Int(response.clientIdentifier ?? "") else { continue }
}
} catch {
print("Error executing translateSequence: \(error)")
}
Suzpf jui vabef o ga-rajxt. Iswawu, wdi dito eronotaz irwxlntanoob buyhiil.gdicqzadi() yumuifkc ott diagt wac cze fugyetviy. Ij tiev iw o tatnesmu ok oboukupti hobx e fwickyapeif, af opus vdi yayodrom bcauzsOyelwanaok, sma ingud, fe rin cka ceguomj mo wya zihbusfeyqugh gefvohvu.
cafeReviews[index].name = response.targetText
Bohextf, ub isqowar gri juceh ok rru guzaKaveafq ces aemj elces (ila ddoibmItayjotuuh) yakm vxo hebqudNacd bnin jxo pixcazqa, bxemx in rga fvebpcotud qupc.
Moi’hz ge ejxu qi bel iq wuvhni igj iftimv on xge jhimopt wunhej sbe heszx wvenw uyt jasi lewotbudz igbuus, kayx ay yiddvihinq aq oxakg ca xla uyomx aw pnob vuhwovx.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.