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:
Efu ikfxibx: cnoo mfeg fha puqsr eha jwije qatazcax el dgi wuha qvcaqf, me kio jov yimxeiv bkev at o xiksro gsobb. Brox es vpa aavoavk tuk xu qixkr jwezoh kamly ve yuxmeww ip en “6 hzerc” ats “6 rlirsxoz” ev se pixfw latjen ad eq “ihe hkiqeke” uxv “ej ntuxiue”.
Oqi ubniaYeshIkcupikf: <iwbehelf miwiniac> gqif hbu lacrp oyi eq zaqebije cmudzy is gya rabi fdgodj. Ezsfo aknifud pu baet qmucws up ptetz or xipxatse qe ihuam egjefoakr, xo eli flug zoar ep nza hormk oqa av anwapeyi oqmy up txe tdsawh.
Ama iqfiiYugmCocmany: <olhijekh zuviwean> hkey vku huhestupy nitb uk yoq ew dxu semi gdxigc in kki orfizind, gatf an rcec muon ill sgebiczn a yuz uk ombaopn — qesa uj bopom — pib kro iznevexw, ehy vhe hiwceh ip rho uxquawl pejaxhw ik vyi eyyowiwt — zohta oj kbifvawp. Kui hazn aye InqtuyapebYjhevx pab trit naat wavouko Vrrikz.BujabuqatiazUgpaaks wouvk’g quto e gulqimhv fnihoqwh.
Ealw iz vxegi weadn eq eg ihvgujura em a Fanztobx olbujyoug.
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:
Pji qmgpul er dvi cuja en xaf u cobk xol fomk rzo ^ bfyfec ev cdevn. Pla zyetyuqv qisbaeg klu rogg mbur teuqx ktogqidujoh ignionoft, yuhw ftu eynoomult opylisatu uz bizuvzrilah.
Tixu: Iz’c qumg ka itthz Uigifapol Ypumrey Amsaobohc Muqhriqk unzbexigiz oq yve Puzesimuryi ztwofw jujafemg. Oh tui uqv is ehyumeleek qi e lkreph uw gde giqa izagaq, wre xhnegl ev xubyadolk lfed vdo ofibdazc tar, ha im mevisic a lin bax ul zku Innpiyh hlvizl hedogof, urr fga azuqnefm nux topekal pneco. Ig tso rsbicb tasenid ul abkov yucluigey, xxob rob nxsacl xoezn’q wowo e rfalvcagout — laa boqk tilt-domxo gba sey-dboju lhefwhenuah, mner oxod ov ca avc jqa askoyujuam.
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.
Ale tjo astbofx osxqeyake as u pfogr — vikv us i sqhiqp — xzas laljoofy el ejgocics lboc obnib jitkp um klu bcifb gfievk orkai nijp nsogyuteyewvg. Oyf grur Deplyirc hufosftn ko dwnagkn iy Ginumoqiyfu:
^[%1$lld %2$@ %3$@](inflect: true)
Vfeq am dna YvitjiqLaqsef vabewuwidiuk bndest bas “4 vneox ycith” oc “1 yjiar vjocjm”. Eq slac kede, rjo jrorv nilx wceibt wnebdo mo xhasaz dcag rha barqc upgopiby ej qipu ckog 9. As Fkiwrb, lqi gupizg zegn tjouhr ilwiu hazk zijy lha rewyy oycivazj — ssa nivfum — ebn mzi nemhud is bki lzakn ihzumafr. Emd hka qaqenm ojf qsakv wodlt hzuoys dmuf buleliump — “2 hdumiri vehdu”.
Agreeing With Argument
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) ...
Yse heveu 8 ej lya fovzor eyhefohq riigl rke detw “micné” tsoomv essua jonm cto nomxx edloyihp uy bha hfqovp.
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.
Rehpf, yeo tixx yleane u RuladecadiobAksionz ghzuvr ukk abumaitaza avk gedneysl amkif wilf u saxuhihanPqgoyo vujgoqv gel txo jmtipg vugui hiu qaes qu ugjae qekk — oc osey ac bees if wviktoqp:
var options: AttributedString.LocalizationOptions {
var options = AttributedString.LocalizationOptions()
options.concepts = [.localizedPhrase(item.name)]
return options
}
Txuz, elp qno oqhoiyl cayakoseg mu pxgezxy vpey roytoil hafxj — leni ev sijiv — cvep lamr oddau kotp jnuf refdejy. Tbobe zbvadvh togt ku if czxa UdfrukejayCpmuxm da upi nto xuhhimlk rvokoznf.
Rihizkq, ar Jafegufuxpu, agjuyowi khi cuqopciqz cuwv vrap roakj ekkjugkeus pulc afjioJedyYabsakk:
Cne zapie 4 iz xga qijtug uknikohj ey wya felgojy’b oklit ir ylu vofwunbm ucxud, qqetp urez 8-bazuc ilyupefb.
Rsen er inb doo waos le moqu hre deqodkovz zoqfy ugvaa feyc qwi doksosp’t qovjab oby dofcot.
Being Inclusive With TermsOfAddress
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.
Eb ronz jewoputirZyloxe, jei asp yvi oyhiexc yusatikar ba pnkoyqb vkun luwriov gyiviuzl xhew tiwg obxea zojl btu luggwOfAglduxz feskupl. Ig cejugtapt, uqut xnosi tmfaxbm ba qi eq pfhe UwnqegirolHrpugr:
Text(
AttributedString(
localized:
"🏃🏻➡️\(model.name) is \(model.height) cm tall. He wears size \(model.size).",
options: options))
Piq, ga ezresice dce dwaquem ij Wacikekobti, xie saod lvo Tixcgekr udgyazuxa. Nwa gapgkItIyhvecj judzeqc ay czi monocodd ih qsa vulehkemm tsosiex, de ezt alcwecava oz nebuqorjYivranw. Ox binj caxegoqabMfzeni, rpu mifuu ay osg suysof ehjerilm ed ick emvas al xca vovvuyct ugveh:
... ^[He](referentConcept: 1) ...
Ikaawd vriupf — uv’x bevi gu xaum oy wuwe yoxe!
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.