Translating a monolingual application

Translating a monolingual application

Talked given @AFUP Paris

418997665c4a3368515ecf9c3d746b95?s=128

Olivier Dolbeau

February 13, 2020
Tweet

Transcript

  1. TRANSLATING A MONOLINGUAL TRANSLATING A MONOLINGUAL APPLICATION APPLICATION AFUP -

    February, 2020
  2. HI, I'M OLIVIER DOLBEAU HI, I'M OLIVIER DOLBEAU

  3. TRANSLATING TRANSLATING A MONOLINGUAL A MONOLINGUAL APPLICATION APPLICATION AFUP -

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

    February, 2020
  5. None
  6. 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!
  7. 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
  8. 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
  9. 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
  10. 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'); // தய ெசய் ஒ பீர்
  11. None
  12. LOOKS SIMPLE! LOOKS SIMPLE!

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

  14. PROBLEM #1 PROBLEM #1 VARIABLES TRANSLATIONS VARIABLES TRANSLATIONS

  15. 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 }
  16. 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. }
  17. 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 } }
  18. ☺ ☺ SOLUTION SOLUTION ICU MESSAGE FORMAT ICU MESSAGE FORMAT

  19. MOST SIMPLE EXAMPLE MOST SIMPLE EXAMPLE translate('drink_beer', [ 'name' =>

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

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

  22. 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 !} }
  23. GENDER EXAMPLE GENDER EXAMPLE translate('drink_beer', [ 'gender' => 'female', ]);

  24. 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!} }
  25. COMBINING VARIABLES COMBINING VARIABLES translate('drink_a_lot', [ 'firstname' => 'Michèle', 'gender'

    => 'female', 'count' => 5, ]);
  26. 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
  27. 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
  28. PROBLEM #2 PROBLEM #2 THE FILE BASED WORFLOW THE FILE

    BASED WORFLOW
  29. FILE BASED WORKFLOW FILE BASED WORKFLOW

  30. FILE BASED WORKFLOW FILE BASED WORKFLOW 1. Developers create a

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

    transla on file. 2. This file is sent to translators.
  32. 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.
  33. 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.
  34. 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
  35. WORKFLOW - 2 LOCALES WORKFLOW - 2 LOCALES Developer Translation

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

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

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

    file Keys Create Translators EN FR ES CO AR ... Translated file Pull
  39. IT'S LIKE SUPER HEROES MOVIES IT'S LIKE SUPER HEROES MOVIES

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

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

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

    developer 2. Complicated workflow 3. Hard to deal with diff.
  43. ☺ ☺ SOLUTION SOLUTION USE A SAAS PRODUCT USE A

    SAAS PRODUCT
  44. LOT OF SOLUTION EXISTS LOT OF SOLUTION EXISTS Loco (h

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

    ps:/ /localise.biz/) PhraseApp Transifex ... (please don't reinvent the wheel)
  46. OUR NEW WORKFLOW OUR NEW WORKFLOW See: h ps:/ /jolicode.com/blog/how-to-properly-manage-transla

    ons-in-symfony
  47. IT SOLVES OUR PROBLEMS (& EVEN MORE) IT SOLVES OUR

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

    PROBLEMS (& EVEN MORE) Developer only have to push keys, nothing else.
  49. 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.
  50. 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
  51. 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/
  52. 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/
  53. 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
  54. ⌨ ⌨ CODE PLEASE. CODE PLEASE.

  55. 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 »
  56. LOT OF LOADERS LOT OF LOADERS

  57. SYMFONY/TRANSLATION SYMFONY/TRANSLATION Supports variables Supports ICU Supports Fallback Supports catalogs

    Provide basic extract feature
  58. WE'RE MISSING SOMETHING WE'RE MISSING SOMETHING HOW TO SYNC TRANSLATIONS

    WITH A SAAS SOLUTION? HOW TO SYNC TRANSLATIONS WITH A SAAS SOLUTION?
  59. 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/
  60. EVEN BETTER WITH SYMFONY EVEN BETTER WITH SYMFONY

  61. PROFILER INTEGRATION PROFILER INTEGRATION

  62. SYMFONY COMMANDS SYMFONY COMMANDS

  63. & MUCH MORE! & MUCH MORE! ✍ Edit in place

    Web UI Auto translate
  64. None
  65. TRANSLATING A TRANSLATING A MONOLINGUAL MONOLINGUAL APPLICATION APPLICATION AFUP -

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

    February, 2020
  67. CRAZY IDEA! CRAZY IDEA!

  68. WHO WORK ON A MONOLINGUAL APP? WHO WORK ON A

    MONOLINGUAL APP?
  69. WHO WORK ON A MONOLINGUAL APP? WHO WORK ON A

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

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

    "There's a typo in the subscrip on funnel, could you correct it?"
  72. git commit -m 'Correct typo translation' git push origin fix-typo

  73. ➕ Create a PR git commit -m 'Correct typo translation'

    git push origin fix-typo
  74. ➕ Create a PR ⏲ Wait for tests git commit

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

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

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

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

  81. SET UP A TRANSLATION WORKFLOW! SET UP A TRANSLATION WORKFLOW!

    Devs are not blockers / bored anymore.
  82. 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.
  83. 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.
  84. USE TRANSLATIONS! USE TRANSLATIONS!

  85. THE END THE END Ques ons then beers!