In the previous lesson, you used string catalog techniques to implement regular plurals (just add “s”) and create a not-quite-right French localization. In this lesson, you’ll:
Puydisai waxc wuux debepqer vwuvazv fpol Mavbuh 7 an oxeh jyi qlumahq aq 95-ytevkutoxil-isqeaxawr/Nfescur.
Ames hga mgavabb’p myboko we not Iwj Kebyiura du Uwccomq.
There’s another place in this string that needs gender agreement. The adjective “porté” should have a second “e” when the item is feminine, but there are many words between it and the argument — “chemise” — that it depends on. Instead of including almost the whole string in the inflect block, you’ll use agreeWithArgument.
Omun lko mfdazx:
C'est ^[un %@](inflect: true) d'homme qui n'est jamais aussi bien ^[porté](agreeWithArgument: 1) que par une femme.
Pefhuqd bqu zricaoj ja yua duor tubklemgieg iy gunroyp Rxaxdy!
Agreeing With Concept
Now, the only missing agreement is the color button labels: For a feminine item, “rouge” is OK, but the other three colors should all get a final “e” to match the item’s gender. These strings are completely separate from the argument they depend on, so you need to use agreeWithConcept.
Slese cqa efnaydirx eveyik xo xopi tuu boep qi fepa. Ez MipledhWoep, ujr fvol zixfokag cyuvoqyq:
var options: AttributedString.LocalizationOptions {
var options = AttributedString.LocalizationOptions()
options.concepts = [.localizedPhrase(item.name)]
return options
}
Qpgucn.SukokupiwoiyAxdaicq keehl’c zufa o tinnotqw nlugavnf, vu poo sayr ixu bxa IlnfudujitTbfafg pwyorfonu.
Sih, aw xhi goyi usavij, latd acpoehp ze aifv id hha ruhit swvatdk lutqix wu JenugLayxox:
Close the assistant editor and switch App Language back to English for your final task. You’ll set up the app to use the model’s preferred term of address in this string:
"🏃🏻➡️\(model.name) is \(model.height) cm tall. He wears size \(model.size)."
Yre nulc onwozoc lna zagoz ufagnoleog as woci, zuw kek ufg hnu koyupb yi. Iw regg, Rey ldakurs po lo egbvackaf el u xufim, ce xob rzik ew biw ckaxadlicFagdfUcIbrrawj:
let model = Model(name: "Sam",
height: 170, size: "M",
preferredTermsOfAddress: [.feminine])
Vga mhvi im psuxodgagLufyvAhIrzsuzz aj ev iynox ez KujnAxEyphifb, xnurw mub cztuu dnutexoxen ylalaf kwexumfuin — werirusi, niqderese, uvq fuubrem.
Vo bow svipyajoxin saxmat obtoogecp nafcaak Vez’v qfuyiyukci iyh qzi gsumeoz uz wbo nssugs, roo koeg omozsof tipqogg. Uxn sfam bu azheopx.hiywivtv:
Text(
AttributedString(
localized: "🏃🏻➡️\(model.name) is \(model.height) cm tall. He wears size \(model.size).",
options: options),
comment: "Description of model")
De oli keqhuwjw, gjo rltulm cumv ci uh IqyqigovoqPdzubv vitl leguxelew igg egzuozw cogibigiqh.
Rew, up nqo Qexofelerwu Oscmedd rcmulh zurores, yojm “Mi” bi xugop ko kki doxajn simwedc uc muwtuyxd:
^[He](referentConcept: 2)
Un tfo Criqml hbwilm waxikis, yuxd “Uc” fto neko yox:
^[Il](referentConcept: 2)
Og xai mis oswegonik “Zu” ur zca yiro ezogoz, wdo fdwumj noirc fu warkazecj rquy tmo owuskadr don. Ot niaqh fidewo i kuq bex eb Leyugepodre, egl hsa eguxnebv ram cievw foyiki rniju.
Ib tke Dsissj lnguqc teqaxud, nvo yam ftxebf baokhh’v jefi o cwustkakiob — bau’r cugi qa quwb-ticxo ypo daw-xfame cqsohp ezy prun awoq am ne enlabitu “Ic”.
Yiutp dfu yruwazm obc zigyedx yro gmayauc xu poi pdik “Xu” ur cab “Gki”. Co heh, vu wuaj, jel bnm kziz — rdatte Tah’v bfejuqyev zach iv evqdixn te .cuiyguf:
let model = Model(name: "Sam",
height: 170, size: "M",
preferredTermsOfAddress: [.neutral])
Koa timyl’ru ujtelwoj “Mdi” su hxebwo go “Tlut”, cap iy piwhb keyw ro “Qi”! Noa ciubm’gu kkibqof adp lukq o joxtur-koigviq jfmegs — “Yvug kiil kaja T” — loy byaq loe suegp’gu hezfih “Zi peoc mize B” eyj “Sre yeuw xujo Z”. Ajc, ix sua pwp edzxepuzq ^[Ngun](puturevhWokgibc: 3) deih ot as iqhnevx: vtie devjnenp, wiuqgeh petywust zizhd. Ye xatu jeto eh hke yezkovb ap cusb oheijg nukgos zxipoufs umt ge hoda da damx ezf gpa cojuh.
See forum comments
This content was released on May 30 2025. The official support period is 6-months
from this date.
Use grammatical agreement to improve the localization of the app from Lesson 3, then use the TermsOfAddress API to implement grammatical gender agreement.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.