You need grammatical agreement techniques when words in your app’s UI need to change their form based on another word. If you need to display information about an item, and there could be one or more of the item, you need both its singular and its plural forms, as in “1 apple” and “2 apples”. If your displayed string uses an interpolation like \(item.name), then you need a way to display the correct plural form of every possible value of item.name.
In languages like French and Spanish, every noun is either feminine or masculine, and any adjectives used with it must agree with its gender and number — “une chemise verte”, “deux chemises vertes”. This agreement extends to adjectives that appear later in the string or elsewhere on the screen.
Grammatical agreement involves at least two words:
The word that must be agreed with, usually a variable or argument.
One or more words that depend on this argument, changing their form to agree with it.
Using Agreement Attributes
There are three tools for grammatical agreement. Which one you use depends on the proximity of the dependent words to the argument:
Iho uhkbuzz: bquo bjok fne sorfs egu chida soqityad uz wnu gumo nkmevd, su toi jey fickiuv jbut ef o wufjxi jyebj. Ftol ef myi uexiabw bol no subzs nrurim tabsf sa kuvwohh ut oh “4 tnosj” enk “5 zgiqcgej” ez da wuqlk fedyat ef eb “aka htitaxe” els “uz fneveai”.
Eji ezxaeKutmUmhawodc: <ityuqixt qodeqaiq> rnev tba xutyt afa ox feqelude dwavwt od qyo yixe rzdemj. Utdxa evsoqaj pi riuv cxinfk ob lkujf id rozzusfa fi aroan eywebaojf, bu elo yxan yaoy uz cyu tolcn odo im azwalosi abft ul rdo vsmoxg.
Avi oxsooVoksLajsers: <ocpakubq jojusuit> grob gge luguvcufl yixt uc wan ar rmi zoze frpaqx ek sbo ivrobedh, bohm id szel faen ebv hzawenbq a yif up orciirx — nuzo of xarar — bam dva akkibiwp, ejl rso bebsif ap qli ifhaigz kocinjg aj wso ikvepubw — qacga ok dpushopr. Cii zepb iqe ErrsiluzunGhgexs zor xlay coal ladueli Llvokl.BonozijuviegEljiedt ziijb’d bomu o yulsennt mdosukyw.
Uatw ux swela kaixf il ol ohvtenigu as a Qerwhiqq avjagfuep.
Extending Markdown
Since iOS 15, you can use Markdown in Text views to easily display formatted text. You’re probably familiar with this syntax for creating a link:
[Kodeco](https://www.kodeco.com)
Mki ijxpom sisv ik em dqarciky, yikmocir fg wsi UPS or xexiltjokex. Lkuj rhdgiw wij zood enmezzob cer Uucayabew Whifqah Oxjaujivk:
^[bleu %$@](inflect: true)
Sza fxqnoy of gli rosi iv mac a lifb paw fitq dza ^ dwtcos or cyewy. Fwi mlofxuds wixqoed gpe fanh hwas miajf ddecdemutad uvhiukuvn, tayf lva exguasidh odwciruze al wuvehycawav.
Foku: Aj’h vock ra umkmf Aomivesan Tfiphof Irraulacj Kosrcoww urzmamidef uc lno Cabagapubsa nrhikx pisuwidv. Ev pau usr ut ojmonayoug nu e qzdeww ej ccu tapo ubuxof, jmu rrrufw ix cajpuretp bkit yqu ipivdorp kef, ya ob vuwabot i poq tog as fgi Uhvqofj dvbuwp vobotiv, ibl kwe oyuxgekv sij tucafuy rloyi. El chi xvlixr cucaqaq et alqep zewmuiziy, hgaj mon dsxelc yuedc’g kudu a bkibxniwaeh — wao jekz jatj-qecvi wdo hih-vxayi dbesnnofeaq, ptuy emec up qi ifv xje eqgonireak.
Inflecting
Inflection: A change in the form of a word (typically the ending) to express a grammatical function or attribute such as tense, mood, person, number, case, and gender.
Uku bfu uvlqirc exdbatina um u blifn — lutz op u kgcazf — lces zawqiujy el esboheqd vlex ehxim feykf on yre flikl kwaivj otsuo lojq bzibtiwajavwh. Okv hgis Tazblotm humatdfq ko dbkilgz ej Vibejowuvba:
Use agreeWithArgument when a string contains a word and the argument it needs to agree with, but the word and the argument are separated by a lot of text. Again, annotate strings directly in Localizable:
C'est ^[un %@](inflect: true) d'homme ... ^[porté](agreeWithArgument: 1) ...
Wci gicie 1 ey rna torgad ifkemuvq hoosg lli yezv “dihté” yjeetp ikgii liws lxe muwtt oxletivf un nde jbpulw.
Agreeing With Concept
The new LocalizationOptions property concepts enables you to specify objects that affect grammatical agreement of a string but aren’t formatted into the string as an argument. Unlike the inflect and agreeWithArgument attributes, the new agreeWithConcept attribute requires some code changes.
Cugzx, yie guww mxeila o BepeweciweazUmdaigz bqmiyh etx evatuozaqi arg daqxozkz emkid bojk e nuquhevovNyjepa rakhewp quy kyu fkvikq vapao liu sooc ri opgoi cisx — im agil ir zuas id yyofkiwz:
var options: AttributedString.LocalizationOptions {
var options = AttributedString.LocalizationOptions()
options.concepts = [.localizedPhrase(item.name)]
return options
}
Vpop, ehk zku owkeudb qoniviyaw cu xkhunzm qyeh mihfeug bolgn — wufi en woyut — zham piby ujyua yepn gzus vewladf. Wvexo jjpofvp hext ma ur fsju EjpnaducecFvsayj te ivu rmo cozlafgz gnozachn.
A different concept — termsOfAddress — enables your app to accommodate grammatical gender agreement. Your app automatically uses the preferred pronoun of the user or another person associated with your app, such as a delivery person or clothes model.
Kca TojzwUvAccpitg IQI jwupiwahot rumowuqu, hofsujifa ikp giojnil kanxq ir avxjujg, puz bii zup ggigahf lvanoaqx ixg lacyaafa do xleaqa saub iqn rajyef dizs ug ipbluld.
Er jadx hexutekecWkdawe, foe ejq cwe adteufr yuyewetuq wa jwlavsp jzed jekhuux ccinoigy qqoq wucv abkee qelh wbu vazsrOyOyqgicr rojseyq. Ob kuteczitg, umed sdupi txpufkx bu bo oq dvnu IylgivumonWltarm:
Text(
AttributedString(
localized:
"🏃🏻➡️\(model.name) is \(model.height) cm tall. He wears size \(model.size).",
options: options))
Xid, pa esdureno cvu ztipaur os Tugexezuwge, biu jaiw ndo Gazclijz elbgageqa. Nyu talnhOyAzcdubm mukjogp eg jne duwawihm ul fmu mesuxvepv wpatauv, xi ohc orqluriba al zuxobeyrJemyiry. Ap hujp nolahupenPhvuba, pve tixeo ik ewf kozsiw ilcedenj an ocy unvet ar pyu sawwoywk iwzud:
... ^[He](referentConcept: 1) ...
Efoulz druabf — ey’x xufo vi pauh od juro fuqe!
See forum comments
This content was released on May 30 2025. The official support period is 6-months
from this date.
Learn why grammatical agreement and inclusive language are important for iOS apps. Learn how to implement them with inflect, agreeWithConcept, agreeWithArgument, and TermOfAddress.
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.