Slide 1

Slide 1 text

TRANSLATING A MONOLINGUAL TRANSLATING A MONOLINGUAL APPLICATION APPLICATION AFUP - February, 2020

Slide 2

Slide 2 text

HI, I'M OLIVIER DOLBEAU HI, I'M OLIVIER DOLBEAU

Slide 3

Slide 3 text

TRANSLATING TRANSLATING A MONOLINGUAL A MONOLINGUAL APPLICATION APPLICATION AFUP - February, 2020

Slide 4

Slide 4 text

TRANSLATING TRANSLATING A MONOLINGUAL A MONOLINGUAL APPLICATION APPLICATION AFUP - February, 2020

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

G11N > I18N > L10N > T8N G11N > I18N > L10N > T8N Globaliza on Interna onaliza on Localiza on Transla on There all numeronyms. I hope you learned something today!

Slide 7

Slide 7 text

GLOBALIZATION GLOBALIZATION The term Globaliza on(g11n) comes into play when a company wants to expand their market outside of their locale place and move into a global market.Globaliza on is simply the umbrella term used to describe the process of bringing i18n and l10n into your product. Vivek Madurai

Slide 8

Slide 8 text

INTERNATIONALIZATION INTERNATIONALIZATION To put it in simple words Interna onaliza on is a process of designing and developing a product so that it can be easily localized for various target markets without any engineering dependency. For example, taking decision on encoding characters stored in your database in Unicode like u -8 instead of la n-1, moving messages to resources files, handling mestamps across mezones Vivek Madurai

Slide 9

Slide 9 text

LOCALIZATION LOCALIZATION The term Localiza on refers to the adop on of a product to a specific language or culture(country/region). Localizing a product includes language transla on, number forma ng, date formats, currency, look and feel etc. Vivek Madurai

Slide 10

Slide 10 text

TRANSLATION TRANSLATION translate('a_beer_please', 'en'); // A beer please translate('a_beer_please', 'fr'); // Une bière s'il vous plaît translate('a_beer_please', 'ar'); // ﺖﺤﻤﺳ ﻮﻟ ةﺮﻴﺑ translate('a_beer_please', 'ta'); // தய ெசய் ஒ பீர்

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

LOOKS SIMPLE! LOOKS SIMPLE!

Slide 13

Slide 13 text

BUT IT'S NOT... BUT IT'S NOT...

Slide 14

Slide 14 text

PROBLEM #1 PROBLEM #1 VARIABLES TRANSLATIONS VARIABLES TRANSLATIONS

Slide 15

Slide 15 text

PLURAL? PLURAL? if (0 === $beers) { translate('no_beer', 'fr'); // Je n'ai pas bu de bière } elseif (1 === $beers) { translate('one_beer', 'fr'); // J'ai bu une bière } else { translate('more_beer', 'fr'); // J'ai bu plusieurs bières }

Slide 16

Slide 16 text

GENDER? GENDER? if ('female' === $gender) { translate('women_drink', 'fr'); // C'est une grosse buveuse. } elseif ('male' === $gender) { translate('men_drink', 'fr'); // C'est un gros buveur. }

Slide 17

Slide 17 text

COMBINED? COMBINED? if ('female' === $gender) { if (0 === $beers) { translate('women_no_beer', 'fr'); // Elle n'a pas bu de bière } elseif (1 === $beers) { translate('women_one_beer', 'fr'); // Elle a bu une bière } else { translate('women_more_beer', 'fr'); // Elle a bu plusieurs bières } } elseif ('male' === $gender) { if (0 === $beers) { translate('men_no_beer', 'fr'); // Il n'a pas bu de bière } elseif (1 === $beers) { translate('men_one_beer', 'fr'); // Il a bu une bière } else { translate('men_more_beer', 'fr'); // Il a bu plusieurs bières } }

Slide 18

Slide 18 text

☺ ☺ SOLUTION SOLUTION ICU MESSAGE FORMAT ICU MESSAGE FORMAT

Slide 19

Slide 19 text

MOST SIMPLE EXAMPLE MOST SIMPLE EXAMPLE translate('drink_beer', [ 'name' => 'Michèle', ]);

Slide 20

Slide 20 text

MOST SIMPLE EXAMPLE MOST SIMPLE EXAMPLE translate('drink_beer', [ 'name' => 'Michèle', ]); {name} boit de la bière.

Slide 21

Slide 21 text

PLURAL EXAMPLE PLURAL EXAMPLE translate('drink_beer', [ 'beers' => 5, ]);

Slide 22

Slide 22 text

PLURAL EXAMPLE PLURAL EXAMPLE translate('drink_beer', [ 'beers' => 5, ]); {beers, plural, =0 {Je n'ai pas bu de bière.} one {J'ai bu une bière.} other {J'ai bu # bières !} }

Slide 23

Slide 23 text

GENDER EXAMPLE GENDER EXAMPLE translate('drink_beer', [ 'gender' => 'female', ]);

Slide 24

Slide 24 text

GENDER EXAMPLE GENDER EXAMPLE translate('drink_beer', [ 'gender' => 'female', ]); {gender, select, female {Tu es une grosse buveuse!} male {Tu es un gros buveur!} other {Tu bois beaucoup!} }

Slide 25

Slide 25 text

COMBINING VARIABLES COMBINING VARIABLES translate('drink_a_lot', [ 'firstname' => 'Michèle', 'gender' => 'female', 'count' => 5, ]);

Slide 26

Slide 26 text

ICU HELL! ICU HELL! Doc: More examples: Online editor: {gender, select, female { {count, plural, =0 {{firstname} ne boit pas.} =1 {{firstname} n'est pas une grosse buveuse, elle n'a bu qu'une seule bière.} other {{firstname} est une grosse buveuse, elle a bu {count} bières!}}} male { {count, plural, =0 {{firstname} ne boit pas.} =1 {{firstname} n'est pas un gros buveur, il n'a bu qu'une seule bière.} other {{firstname} est un gros buveur, il a bu {count} bières!}}} other { {count, plural, =0 {{firstname} ne boit pas.} one {{firstname} a bu une seule bière.} other {{firstname} a bu {count} bières!}}}} h p:/ /userguide.icu-project.org/formatparse/messages h ps:/ /symfony.com/doc/current/transla on/message_format.html h ps:/ /format-message.github.io/icu-message-format-for- translators/editor.html

Slide 27

Slide 27 text

TIP: USE A TRANSLATION KEY! TIP: USE A TRANSLATION KEY! h ps:/ /symfony.com/doc/current/best_prac ces.html#use-keys-for-transla ons-instead- of-content-strings h ps:/ /php-transla on.readthedocs.io/en/latest/best-prac ce/index.html

Slide 28

Slide 28 text

PROBLEM #2 PROBLEM #2 THE FILE BASED WORFLOW THE FILE BASED WORFLOW

Slide 29

Slide 29 text

FILE BASED WORKFLOW FILE BASED WORKFLOW

Slide 30

Slide 30 text

FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a transla on file.

Slide 31

Slide 31 text

FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a transla on file. 2. This file is sent to translators.

Slide 32

Slide 32 text

FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a transla on file. 2. This file is sent to translators. 3. Translators send back a translated file.

Slide 33

Slide 33 text

FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a transla on file. 2. This file is sent to translators. 3. Translators send back a translated file. 4. Developers integrate this file in applica on.

Slide 34

Slide 34 text

FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a transla on file. 2. This file is sent to translators. 3. Translators send back a translated file. 4. Developers integrate this file in applica on. 5. REPEAT

Slide 35

Slide 35 text

WORKFLOW - 2 LOCALES WORKFLOW - 2 LOCALES Developer Translation file Keys Create Translators EN FR ... Translated file Pull

Slide 36

Slide 36 text

WORKFLOW - 3 LOCALES WORKFLOW - 3 LOCALES Developer Translation file Keys Create Translators EN FR ES ... Translated file Pull

Slide 37

Slide 37 text

WORKFLOW - 4 LOCALES WORKFLOW - 4 LOCALES Developer Translation file Keys Create Translators EN FR ES CO ... Translated file Pull

Slide 38

Slide 38 text

WORKFLOW - 5 LOCALES WORKFLOW - 5 LOCALES Developer Translation file Keys Create Translators EN FR ES CO AR ... Translated file Pull

Slide 39

Slide 39 text

IT'S LIKE SUPER HEROES MOVIES IT'S LIKE SUPER HEROES MOVIES

Slide 40

Slide 40 text

FAR FROM PERFECT FAR FROM PERFECT 1. Time consuming for developer

Slide 41

Slide 41 text

FAR FROM PERFECT FAR FROM PERFECT 1. Time consuming for developer 2. Complicated workflow

Slide 42

Slide 42 text

FAR FROM PERFECT FAR FROM PERFECT 1. Time consuming for developer 2. Complicated workflow 3. Hard to deal with diff.

Slide 43

Slide 43 text

☺ ☺ SOLUTION SOLUTION USE A SAAS PRODUCT USE A SAAS PRODUCT

Slide 44

Slide 44 text

LOT OF SOLUTION EXISTS LOT OF SOLUTION EXISTS Loco (h ps:/ /localise.biz/) PhraseApp Transifex ... (please don't reinvent the wheel)

Slide 45

Slide 45 text

LOT OF SOLUTION EXISTS LOT OF SOLUTION EXISTS Loco (h ps:/ /localise.biz/) PhraseApp Transifex ... (please don't reinvent the wheel)

Slide 46

Slide 46 text

OUR NEW WORKFLOW OUR NEW WORKFLOW See: h ps:/ /jolicode.com/blog/how-to-properly-manage-transla ons-in-symfony

Slide 47

Slide 47 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE)

Slide 48

Slide 48 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else.

Slide 49

Slide 49 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else. Translators now have a dedicated tool.

Slide 50

Slide 50 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else. Translators now have a dedicated tool. SAAS product = primary data store

Slide 51

Slide 51 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else. Translators now have a dedicated tool. SAAS product = primary data store You have access to the whole history! \o/

Slide 52

Slide 52 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else. Translators now have a dedicated tool. SAAS product = primary data store You have access to the whole history! \o/ You can add context to transla ons \o/

Slide 53

Slide 53 text

IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else. Translators now have a dedicated tool. SAAS product = primary data store You have access to the whole history! \o/ You can add context to transla ons \o/ ⬇ Automa cally retrieve transla ons during deploy

Slide 54

Slide 54 text

⌨ ⌨ CODE PLEASE. CODE PLEASE.

Slide 55

Slide 55 text

SYMFONY COMPONENT FTW! SYMFONY COMPONENT FTW! composer require symfony/translation use Symfony\Component\Translation\Translator; $translator = new Translator('fr_FR'); $translator->addResource('array', [ 'a_beer_please' => 'Une bière s\'il vous plaît', ], 'fr_FR'); echo $translator->trans('a_beer_please'); // « Une bière s'il vous plaît »

Slide 56

Slide 56 text

LOT OF LOADERS LOT OF LOADERS

Slide 57

Slide 57 text

SYMFONY/TRANSLATION SYMFONY/TRANSLATION Supports variables Supports ICU Supports Fallback Supports catalogs Provide basic extract feature

Slide 58

Slide 58 text

WE'RE MISSING SOMETHING WE'RE MISSING SOMETHING HOW TO SYNC TRANSLATIONS WITH A SAAS SOLUTION? HOW TO SYNC TRANSLATIONS WITH A SAAS SOLUTION?

Slide 59

Slide 59 text

PHP-TRANSLATION FTW PHP-TRANSLATION FTW A github organisa on dedicated to transla ons Allow to sync transla ons with SAAS solu ons ⬇ Provide advanced extract feature Doc: h ps:/ /php-transla on.readthedocs.io/en/latest/

Slide 60

Slide 60 text

EVEN BETTER WITH SYMFONY EVEN BETTER WITH SYMFONY

Slide 61

Slide 61 text

PROFILER INTEGRATION PROFILER INTEGRATION

Slide 62

Slide 62 text

SYMFONY COMMANDS SYMFONY COMMANDS

Slide 63

Slide 63 text

& MUCH MORE! & MUCH MORE! ✍ Edit in place Web UI Auto translate

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

TRANSLATING A TRANSLATING A MONOLINGUAL MONOLINGUAL APPLICATION APPLICATION AFUP - February, 2020

Slide 66

Slide 66 text

TRANSLATING A TRANSLATING A MONOLINGUAL MONOLINGUAL APPLICATION APPLICATION AFUP - February, 2020

Slide 67

Slide 67 text

CRAZY IDEA! CRAZY IDEA!

Slide 68

Slide 68 text

WHO WORK ON A MONOLINGUAL APP? WHO WORK ON A MONOLINGUAL APP?

Slide 69

Slide 69 text

WHO WORK ON A MONOLINGUAL APP? WHO WORK ON A MONOLINGUAL APP? WITHOUT TRANSLATIONS? WITHOUT TRANSLATIONS?

Slide 70

Slide 70 text

"Can you change the transla on in the footer please?"

Slide 71

Slide 71 text

"Can you change the transla on in the footer please?" "There's a typo in the subscrip on funnel, could you correct it?"

Slide 72

Slide 72 text

git commit -m 'Correct typo translation' git push origin fix-typo

Slide 73

Slide 73 text

➕ Create a PR git commit -m 'Correct typo translation' git push origin fix-typo

Slide 74

Slide 74 text

➕ Create a PR ⏲ Wait for tests git commit -m 'Correct typo translation' git push origin fix-typo

Slide 75

Slide 75 text

➕ Create a PR ⏲ Wait for tests ⏲ Wait for review git commit -m 'Correct typo translation' git push origin fix-typo

Slide 76

Slide 76 text

➕ Create a PR ⏲ Wait for tests ⏲ Wait for review ⏲ Merge your PR git commit -m 'Correct typo translation' git push origin fix-typo

Slide 77

Slide 77 text

➕ Create a PR ⏲ Wait for tests ⏲ Wait for review ⏲ Merge your PR Deploy git commit -m 'Correct typo translation' git push origin fix-typo

Slide 78

Slide 78 text

➕ Create a PR ⏲ Wait for tests ⏲ Wait for review ⏲ Merge your PR Deploy And some mes, there is an issue to deal with... git commit -m 'Correct typo translation' git push origin fix-typo

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW!

Slide 81

Slide 81 text

SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW! Devs are not blockers / bored anymore.

Slide 82

Slide 82 text

SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW! Devs are not blockers / bored anymore. It's easier / quicker for anyone to update transla ons.

Slide 83

Slide 83 text

SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW! Devs are not blockers / bored anymore. It's easier / quicker for anyone to update transla ons. It's a first step done for G11N.

Slide 84

Slide 84 text

USE TRANSLATIONS! USE TRANSLATIONS!

Slide 85

Slide 85 text

THE END THE END Ques ons then beers!