Slide 1

Slide 1 text

Multilingual Sites in Craft 3

Slide 2

Slide 2 text

Zoltan Varady @drifteaur Novi Sad • Budapest Farm Studio farm.co.hu

Slide 3

Slide 3 text

There are many kinds of multilingual sites

Slide 4

Slide 4 text

Business cases

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

1:1 translation Same structure, same content, just translated

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Different content Different audiences; or not enough resources to translate everything

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Your experiences?

Slide 16

Slide 16 text

Language is not culture

Slide 17

Slide 17 text

Color is language

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Scripts can have cultural and political overtones

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Translation Workflows

Slide 23

Slide 23 text

Who will do the translation? Internally, by the content team By the developers Outsourced to a translation agency via an API? Automated translation

Slide 24

Slide 24 text

Translation workflow Do you need to publish all languages at once? Proofreading / approval Translation management tools


Slide 25

Slide 25 text

Let’s get crafty

Slide 26

Slide 26 text

To borrow from Drupal Content translation (entries, categories, etc) Interface translation (static messages, Craft::t, twig’s | t filter) Configuration translation (settings, email templates…)

Slide 27

Slide 27 text

Content and fields

Slide 28

Slide 28 text

Belgian Site Group Swiss Site Group Schwiizerdütch de-CH Swiss French fr-CH Swiss Italian it-CH Flemish nl-BE Belgian French fr-BE Belgian German de-BE

Slide 29

Slide 29 text

Not So Fancy Fancy Shoes en-GB Shirts en-GB Pants en-GB Shoes en-GB Shirts en-GB Pants en-GB

Slide 30

Slide 30 text

Craft 3 only cares about sites

Slide 31

Slide 31 text

Craft 3 only cares about sites Content table Sites table

Slide 32

Slide 32 text

Multi-valued fields Matrix Categories, tags Related entries Assets but not Tables (use Matrix or Super Table instead if you need it)

Slide 33

Slide 33 text

pizza dough tomatoes mozzarella ham pineapple pizzatészta paradicsom mozzarella kolbász pizza dough tomatoes mozzarella pizzatészta paradicsom mozzarella

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

The power of t()

Slide 36

Slide 36 text

Localization is more than words 05/06/2018 vs 06/05/2018 vs 2018. 06. 05. 2,100.99 vs 2 100,99 $100 vs 100 EUR GMT UTC DST CET PST 1 hour, 2 hours vs نابْح ُ ص باح ْ صَأ بِحاص

Slide 37

Slide 37 text

Yii 2 + INTL = FTW {{ 'Hello {name}!' | t({ name: 'Zoltan' }) }} => Hello Zoltan {{ 'Hello {0}!' | t([‘Zoltan’]) }} => Hello Zoltan {{ 'Total: {amt,number}' | t({amt: 2510.99}) }} => 2,510.99 {{ 'You are the {n,spellout,%spellout-ordinal} in line' | t({n: 47}) }} => You are the forty-seventh in line {{ 'Eres {n,ordinal,%digits-ordinal-feminine}' | t({n: 1}) }} => Eres 1.ª

Slide 38

Slide 38 text

{{ '{d,date,short}' | t({d: date().timestamp}) }} => 9/18/18 {{ 'Today is {d,date,long}' | t({d: date().timestamp}) }} => September 18, 2018 {{ 'Today is {d,date,yyyy-MM-dd}' | t({d: date().timestamp}) }} => 2018-09-18 {{ 'Last updated: {0, duration,%with-words} ago' | t([15024]) }} => Last updated: 4 hours, 10 minutes, 24 seconds ago

Slide 39

Slide 39 text

https://intl.rmcreative.ru/

Slide 40

Slide 40 text

{{ 'You {likeCount,plural, offset: 1 =0{did not like this} =1{liked this} one{and one other person liked this} other{and # others liked this} } ' | t ({likeCount: 2}) }} => You and one other person liked this

Slide 41

Slide 41 text

Configuration translation No standardized way of storing or displaying translations Plugins need to take care of it themselves Drupal does it via a configuration schema

Slide 42

Slide 42 text

The devil is in the details

Slide 43

Slide 43 text

Entry points http://designhet.hu/- http://designweek.hu/ http://p-rp.hu/hu - http ://p-rp.hu/en a single index.php is enough (no need for en/index.php)

Slide 44

Slide 44 text

Site aliases general.php 'aliases' => [ '@webHu' => getenv('HU_BASE_URL'), '@webEn' => getenv('EN_BASE_URL'), '@assetBaseUrl' => getenv('ASSET_BASE_URL'), '@assetBasePath' => getenv('ASSET_BASE_PATH'), ], .env HU_BASE_URL="https://designhet.hu/2018/" EN_BASE_URL="https://designweek.hu/2018/" ASSET_BASE_URL="https://designhet.hu/2018/" ASSET_BASE_PATH=“/home/asdf/2018/“

Slide 45

Slide 45 text

Routes return [ 'hirek' => ['template' => 'news/index'], 'esemenyek' => ['template' => 'events/index'], ]; Section settings config/routes.php Route settings

Slide 46

Slide 46 text

Per-site templates “create a new sub-folder in your templates folder, named after your site's handle, and place the templates in there”

Slide 47

Slide 47 text

Per-site configuration not directly possible - general.php is loaded early in the bootstrap process Craft has no idea about the current site or language at the time workarounds: use environment vars, seperate index.php entry points, or arrays keyed by site handle

Slide 48

Slide 48 text

currentSite currentSite.name => English currentSite.handle => default currentSite.language => en-GB currentSite.baseUrl => @web/ {{ alias(currentSite.baseUrl) }} => https://designhet.hu/

Slide 49

Slide 49 text

Twig craft.app.sites => all sites currentSite.group.sites => sites in current group entry.getSupportedSites => sites that entry is active for

Slide 50

Slide 50 text

Language switchers Site Switcher SEOMatic Language Redirector

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

flagsarenotlanguages.com

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Names Zoltan Várady Várady Zoltán Várady Zoltánné Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de laSantísima Trinidad Ruiz y Picasso validation and sorting can be challenging https://www.w3.org/International/questions/qa-personal-names

Slide 55

Slide 55 text

Addresses Commerce Guys addressing library NSM Fields

Slide 56

Slide 56 text

Social Media Twitter Weibo VKontakte Tumblr

Slide 57

Slide 57 text

Challenges in Craft Configuration translation Structure entries always propagate Collaborative translation of core and plugins transifex, localize.drupal.org

Slide 58

Slide 58 text

Summary consider your audience what needs to be translated translation is not just words; see culture, colors, images… who are the translators, what is the workflow once you have this, use the tips given to map it onto a Craft site

Slide 59

Slide 59 text

Acknowledgements thanks to Gábor Hojtsy (@gaborhojtsy), multilingual initiative lead for Drupal 6 and 7, for reviewing my draft

Slide 60

Slide 60 text

Find Me Zoltan Varady zoltan@farm.co.hu @drifteaur Farm Studio / https://farm.co.hu

Slide 61

Slide 61 text

Resources http://responsivenews.co.uk/post/123104512468/13-tips-for-making-responsive-web-design (BBC) http://www.flagsarenotlanguages.com/blog/page/3/ https://docs.craftcms.com/v3/sites.html https://docs.craftcms.com/v3/localization.html https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n https://intl.rmcreative.ru/ https://www.w3.org/International/questions/qa-personal-names https://www.becomingadatascientist.com/2015/09/19/human-name-variations-in-databases/