Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
UsingAn(Pa+ernsinInterna(onaliza(onTraining
ElsebethFlarup
Page 1 .
Thejobofaninterna(onaliza(onevangelist
“SisyphusGif-sigh.gif”byChris2naHendricksislicensedunderCCBY4.0 2
!MEforthelast20years…
MyusualMO1. Ensuremanagementsupport
2. Createguidelinesandtrainingsessions• Definethebasicconcepts• Explainwhyitisimportant
• Categories• -Textencoding
• -Culturalformats
• -Translatability
• -etc.
• Highlightdosanddon’tsforeach• Providecodesnippetsasexamples
3
Somethinglikethis• Storeandprocessdatainlocale-neutralformat
• BUT:Alwaysdisplaylocale-specificformatstoenduser
• Usethelocale-awareAPIsfromyourprogrammingplaQorm
• Neverhardcodeformatsfordate/(me/numberetc.
• Externalizealluser-visiblestringstostandardtransla(onfiletypes• Andsoon…
4
Thestonekeptrollingbackdownthough…• A+en(on/par(cipa(onduringtrainingsessionsusuallynotgreat“Idon’tthinkIwilleverworkoninterna2onaliza2onissues”
“Howhardcanitbe…”
• S(llhearingques(onslike“Can’ttheyjustuseworkarounds?”
“Thiscanwait2llnextrelease,right?”
• Interna(onaliza(onissuesinternalizedasminor,impactnotreallyunderstood
5
6
7
8
9
10
11
12
13
14
UsingEnglishlanguagean(pa+erns• Alotmoreengagementduringface-to-facetraining
• Everybodyeasilyrecognizesalmosteverythingthatiswrongaccordingtoen_USlocaleexpecta(ons,andUSEnglishlanguage
• Actual“ahaexperiences”whenreferringbacktoini(alEnglishexamplesforeachcategory
• WhatwejustsawasparodyinEnglish:happensinotherlanguages/localesallthe8mewhenbestprac8cesarenotfollowed
15
Translatabilitybestprac(ces• Donothardcodeanyuser-visiblestrings=>• Usetherightencoding=>• Donotconcatenatestringsincode=>
• Bewareof“naturallanguage”UI=>• Alwaysincludepunctua(onaspartofstring=>• Useplaceholderswithcare=>
• DonotcreateUIstringsthatlooklikecode=>• Handlepluralforms=>
• AllowforexpansionspaceinUIs=>
• Donotreusestringsindifferentcontexts=>
16
Culturalformatsbestprac(ces• Usethedate(meforma^ngAPIs=>
• Donothardcodeorderofdateelements=>
• Uselocale-awarewidgets(firstdayofweek,etc.)=>
• UseAPIstoformatnumber/currency/percent=>
• Usedatatypes,orderappropriateforregion=>• Bewareofhardcodedvalida(onrules=>
• Uselanguage-specificsortorder=>
17
Valueofexampletypes
Bestexamples/mostimpact
Reasonableeffect
S(lltryingtocomeupwithgood/be+erexamples
18
Varioustypesofconcatena2on
Date/2me/calendar/numberformats
Sortorder
UItrunca2ons
Datatypeslikenamesandaddresses
Valida2onrules(fore.g.phonenumbers)
Somestringconcatena2onandplaceholderusageissuescan’treallybedemonstratedusingEnglish
Contextissuesalsodifficulttodemonstrateconvincingly
Genderrelatedissues
Pluralformatissues
Somesampletrainingsec(ons
Concatena(on
Rememberthesestrings?
21
That’stheeffectyougetinotherlanguageswhensentencefragmentsareconcatenatedincode,withnoop(onforthetranslatortoswitchtheorderaround
Stringconcatena(on
• Concatena(ngsentencefragmentsincodeisverytemp(ngasaquickanddirtyworkaround,butitbasicallymakescorrecttransla(onsintomostlanguagesimpossible
• Assumethattranslatorsneedtorestructuresentencestotakedifferentsyntaxintoaccount
English:“Bobsent10emailsyesterday”“10daysago?”
LanguageX:“Emails10yesterdaysentBob”“¿for10daysago?”
• So,avoidconcatena(ngpar(alstringstoformasentence–createanewstringforthecompletesentenceinstead
• AND:alwaysincludeplaceholdersandpunctua(oninthestring,don’tassumeyoucanprefix/appendincode
• Somelanguagesusedifferentpunctua(oncharacters,andtheymayneedtobeplaceddifferentlyrela(vetothetextstrings
22
© Guidewire Software, Inc. All rights reserved. Do not distribute without permission. Page 23
© Guidewire Software, Inc. All rights reserved. Do not distribute without permission. Page 24
// BAD, order may be incorrect for some languages
"agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.Open":"Open",
"agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.PolicyChanges":"PolicyChanges”
<divclass="2le-2tle">{{'agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.Open'|translate}}<br/>
{{'agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.PolicyChanges'|translate}}</div>
// GOOD, create a single string
"agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.OpenPolicyChanges":”Open<br>PolicyChanges”,
<divclass="2le-2tle">{{'agent.direc2ves.AgentDashboardDirec2ve.agent-dashboard.OpenPolicyChanges'|translate}}
</div>
25
// BAD
"agent.ac2vity.date.filter.daysago":"daysago",
return'!'+dateDifference+$filter('translate')('agent.ac2vity.date.filter.daysago');
// GOOD – punctuation and placeholder in translatable string
"agent.ac2vity.date.filter.daysago":”!{{dateDifference}}daysago",
return$filter('translate')('agent.ac2vity.date.filter.daysago’,{dateDifference:date.result});
Concatena(oncanalsobedoneviaUIcontrols
• UIelementswhichusesentencestructuremayalsoneeddifferentorderinotherlanguages
• InJapanese,thedatecomesbeforethe“by”
• TrytoavoidthistypeofUIifpossibleVerydifficulttomakeflexibleenoughtofitstructureofalllanguages
• YoumayhavetomakeorderofUIcontrolsconfigurablebylanguage
26
Placeholders
Rememberthisstring?
28
That’sapaleversionofwhathappensinotherlanguagesyouuseplaceholdersinappropriately.Manylanguageshavesyntaxrulesaboutgendercorrespondencebetweennounsandadjec(ves,forinstance.Resul(nginpoten(allydisastroustransla(ons
Createanrecurringmee(ngwithyouragent
Placeholders
• Mainrules• Onlyuseplaceholdersifabsolutelynecessary,andonlyforvaluesthatcanonlybeknownatrun2me
• Createseveralstringsratherthanusingplaceholderifsubs2tu2onvalueisacommonnounorverb
“agent.create.new.ques(on”:“Createnew{{0}}?”where{{0}}canbereplacedby“policy”or“quote”
• Guaranteedtocausegendercorrespondenceissuesinotherlanguages,dependingonreplacementvalue(insomelanguagesadjec2vesneeddifferentformdependingonnountheyapplyto)
• Germannounscanbemasculine,feminineorneuter,forinstance.Requires3differentadjec2veconjuga2ons(and3differentgendermarkers:“der”,“die”,“das”asopposedtojust“the”inEnglish)
• Inexampleabove,justcreate2separatestringswithoutplaceholders
29
Placeholders–example2
Cannot {0} Policy {1} : This account is held by a {2}, which is not suitable for {3} policy.
becomes:
Cannot move Policy 12345 : This account is held by a Company, which is not suitable for Personal Auto policy
- Translatorsseeonlytheisolatedstring–havenoideawhatthepossiblesubs(tu(onvaluesare
- NEVERuseplaceholderforcommonnounorverb- Insomelanguages,syntaxdiffersdependingonfirstlemerofnoun/verb(“impossibled'avancer”,but“impossibledesupprimer”)
- EveninEnglish,orthographyisawkward(uppercaseCompany,missingar(cleforPersonalAuto)
Versionthatwouldbetranslatable(noplaceholderforverb,nounsremovedfromsyntaxcontext):
Cannot move policy {0}. Mismatch between account type ({1}) and policy type ({2})
30
Placeholders–example3
• Englishsourcestringsconstructedfromfragmentsviaotherstringfilekeys
The Catastrophe {Term.Selected.Lower} is inconsistent with the {Term.Claim.Possessive.Lower} Loss Cause of {1}
Some of the {Term.Selected.Lower} reviews could not be completed.
{Term.Selected.Lower} -> “selected”
{Term.Claim.Possessive.Lower} -> “claim’s”
- Intransla(ons,nouns,adjec(ves,verbsgetconjugateddependingonsentencesyntax,soallsuchvariableshavetobereplacedwithrealstrings–asinGerman:
Die gewählte Catastrophe stimmt nicht mit der Schadensursache {1} überein.
Einige der ausgewählten Reviews konnten nicht fertiggestellt werden.
• Transla(ngstringscontainingsuchvariablesbecomeshugelymoreexpensiveand(me-consuming(translatorwillhavetohuntforrealvaluesofplaceholderstrings)
31
Pluralformats
Plurals–rememberthis:
• Englishissimple–just2forms,singularandplural-2stringscancoverallpossibili(es:singular=Youhave{0}daylen
plural_zero=Youhave{0}dayslen
• Youcanevenuseasimplehack:“Youhave{0}day(s)leo”toavoidprobleminEnglish
• Fineforsomelanguages,butfarfromall–upto6formsneededinsomelanguages
• Polish,Russian,forexample(andevenFrenchusesslightlydifferentrules):
33
LocalizingUIStrings–pluralforms
Thetablebelowshowswhatstringisreturneddependingontheac(velanguage
Ac(veTransla(on
n NoTransla2on English Russian0 "You have 0 new message(s)." "You have 0 new messages." "У вас 0 новых сообщений."
1 "You have 1 new message(s)." "You have 1 new message." "У вас 1 новое сообщение."
2 "You have 2 new message(s)." "You have 2 new messages." "У вас 2 новых сообщения."
37 "You have 37 new message(s)." "You have 37 new messages." "У вас 37 новых сообщений."
Handlingplurals
• StringscodedforEnglishdonotworkEitherjustincorrectwhendisplayedwithcertaindigits
Orinsanelyuglytransla2onslike“epizód/a/y”totrytoincludeallpossibleformatsinonetransla2on(Slovakinthiscase)
• Usei18nlibrarywithsupportforpluralformatsinalllanguages
• Oruseworkaround:Use“subject:predicate”formatinsteadof“naturallanguage”:“Dayslen:{0}”
35
Stringcontext
Stringcontext
• Manyiden(calstringsareusedinmanydifferentcontextsOn/Off/Custom/High/Low/Medium/Normal/Private/Personaletc.
• Howtheyshouldbetranslateddependsonthegenderofassociatednoun
• Needdifferentversionsofsuchstringsforeverysinglenountheyapplyto
• Again,Englishissimple,sotheexampledoesnotconveyhowprevalentthiscanbe:
37
UItrunca(ons
ProvideexpansionspaceintheUI
• Expectthatstringswillexpandinotherlanguages• Forshortstringsupto10characters,expectatleast100%expansion• Don’texpecttranslatorscan“justmaketransla(onsshorter”
• Insomecases,therereallyarenoshorterwords
• Sodonothardcodecontrolsizes,allowdynamicresizingifpossible–soyouavoid…
39
Date/(me/numberformats
Dosanddon’ts• Alwaysdisplaylocale-specificformatstoenduserDisplaydate/2me/numbers/currency/sortorder/calendar/measurements/etc.accordingtouser’spreferences
Butstoreandprocesstheminlocale-neutralformatinternally
• UseAPIsfromprogrammingplaQormtoperformforma^ngAllprogrammingplavormshavestandardAPIsforaccessinganddisplayingthelocalecategories
Don’thardcodeformat:
Don’thardcodepa+ern:
Don’tassumefirstdayofweek,weekends,etc.:
41
Dosanddon’ts• Don’tusestringsintransla(onfilesforlocaleforma^ng–uselocaledatafromplaQorm(CLDRinmostcases)Namesofdays/months,date/2mepamerns,etc.
Nomaintenanceandtransla2oncost
Doesnotrelyontranslatorscorrectlyhandlingformawngpamerns
• Translatorshavedifficultyunderstandingformatpamernslike“EEE,MMMd,yyyy”
• Theyeitherleavethemunlocalized,or“translate”to“UUU,MMM,dåååå”
Supportformanymorelocalesandconsistentformatscomparedtoplacingformawngpamernsintranslatablefiles
Allowsustosupportregionalpreferenceswithno2etoUItransla2ons
Ifyouneedcustomformats,useICU’s“skeletons”
42
Sortorder
Issortorderreallyimportant?
44
• Sortof☺
• Whenalistofcountrieswithseveralhundredentriesissortedlikethis,itbecomes“challenging”tofindwhatyouarelookingfor–inanylanguage
• Comparesortorderinlistsonright–radicallydifferentexpecta(onsforDanishvs.Englishlanguageusers
Dataelements,valida(onrules
46
Dosanddon’ts• English-speakinguserintheUSwouldbeunhappywithpreviousscreen• Japanese-speakinguserinJapanequallyunhappywithUS-centriccontent• Understandrequirementsupfront
• Usealreadyimplementedname/address/phoneformatwidgets
• Don’thardcodevalida(onrulestoexpectdatatoconformtoUSregiondefaultsExamples:zipcodes,telephoneformats
47