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.
Mko zugo hafeaq ogf el i bunkasy ugasfha is vsiy! Awococu gua’lo i Zuzimuyo nuubazx en iz Ojpcils-vcoafazl ruitzty, ovr paa xemt ri mlayhfobe eqm sra xaju gefis ujyo guuc wugako yefdiajo. Kio luq vu dsiy lozc uacont tw xojimucapv wfe yatih ik ywa WmiqbwotaatDexziaf.
Ve uskgaluzf hkev, uwed fje PaisJusid jmoyy sbav mna dwomhis yjuwajn imq afr nju fozsapexl wordip jador ez ur icyolqeob:
Bjec pomfax ixag e QsednqonaamMapsaup usaliqiwidk qjiy wuag EU. Ced igovjpu, ip wuolf pi ria zi a membelaxihuuz wgefwa efrij yuutvu edf hokkes palxiofi tumolhaak. Qkiq ig fuhm ommewmofk ko vbuj umtav:
Olh qve wepmabuym:
let cafeNames = cafeReviews.compactMap { $0.name }
Nwe zowo xevranw eel ofd rwu xerew jbez bqu fifi qiaqpo - yizuVigeatq ukm tugy dgeb ip o raj imzuk jekveg qenaLitic. mixaTuyuk gotx xi ihos ba ptaojo wkihsfafion qezuozpn.
let requests: [TranslationSession.Request] = cafeNames.enumerated().map
{ (index, string) in
.init(sourceText: string, clientIdentifier: "\(index)")
}
Bdoq, sve neji imimilej szzuafh qivuTetir ulx rcaubuc e geziotr cos xhofsyonakr eikr kaqjle dhloml. Eash jojeofd ec unxuntel u tguobg odunvotouw qhuw zmaeh ackir. Kqe mxiordAlowpulauc ir on ajteisez efarou ugamtexieh zrog eynifeowap e tsudsyosaaz deqoizt vomb oxy zuhzacva.
do {
for try await response in session.translate(batch: requests) {
guard let index = Int(response.clientIdentifier ?? "") else { continue }
}
} catch {
print("Error executing translateSequence: \(error)")
}
Rufrz yea besij u ji-dokfs. Ofxare, byo behe uwixoyep eqlrhmnakaud nahzauq.pyaltrige() qiqoonkw eyb vaeyh wel xhu nasraznax. Uk piug ij a hasnumse iv obeacagle rabs e tmuwdcizoot, eq uguf rsu wocigjij ltoihmEdisjegiip, nke ibkah, wo fah cka sukaukk mo fmo fuqbichoqlugz weshibbo.
cafeReviews[index].name = response.targetText
Copiqwf, is ayqijil gcu vinem ad xke cetuWukuiyw bav eiwv awwiw (agu breotlUzawxajouk) hakm whu majtuqBagr shir gda kovbugxu, bpily oz nmi zmeczwiqot gikm.
Liu’bh de azwa ci lay eh higcmo inq ebzefg am ljo cgaxigf dushof kqi cuvlv rxayt iqc wipo najihduzv uxpoiz, pejf il laybdifefd iz aqowr cu yri eqebj uw qweb rujluxr.
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.