Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Translating a monolingual application

Translating a monolingual application

Talked given @AFUP Paris

Olivier Dolbeau

February 13, 2020
Tweet

More Decks by Olivier Dolbeau

Other Decks in Programming

Transcript

  1. 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!
  2. 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
  3. 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
  4. 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
  5. 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'); // தய ெசய் ஒ பீர்
  6. 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 }
  7. 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. }
  8. 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 } }
  9. 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 !} }
  10. 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!} }
  11. 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
  12. 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
  13. FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a

    transla on file. 2. This file is sent to translators.
  14. 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.
  15. 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.
  16. 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
  17. WORKFLOW - 2 LOCALES WORKFLOW - 2 LOCALES Developer Translation

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

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

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

    file Keys Create Translators EN FR ES CO AR ... Translated file Pull
  21. FAR FROM PERFECT FAR FROM PERFECT 1. Time consuming for

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

    developer 2. Complicated workflow 3. Hard to deal with diff.
  23. LOT OF SOLUTION EXISTS LOT OF SOLUTION EXISTS Loco (h

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

    ps:/ /localise.biz/) PhraseApp Transifex ... (please don't reinvent the wheel)
  25. IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR

    PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else.
  26. 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.
  27. 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
  28. 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/
  29. 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/
  30. 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
  31. 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 »
  32. WE'RE MISSING SOMETHING WE'RE MISSING SOMETHING HOW TO SYNC TRANSLATIONS

    WITH A SAAS SOLUTION? HOW TO SYNC TRANSLATIONS WITH A SAAS SOLUTION?
  33. 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/
  34. WHO WORK ON A MONOLINGUAL APP? WHO WORK ON A

    MONOLINGUAL APP? WITHOUT TRANSLATIONS? WITHOUT TRANSLATIONS?
  35. "Can you change the transla on in the footer please?"

    "There's a typo in the subscrip on funnel, could you correct it?"
  36. ➕ Create a PR ⏲ Wait for tests git commit

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

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

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

    for review ⏲ Merge your PR Deploy git commit -m 'Correct typo translation' git push origin fix-typo
  40. ➕ 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
  41. SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW!

    Devs are not blockers / bored anymore.
  42. 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.
  43. 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.