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

Internationalisation à Kapten

Internationalisation à Kapten

L’internationalisation est un sujet complexe comprenant de nombreuses problématiques que beaucoup de startups rencontrent mais priorisent peu dans leurs premières années d'existence.

Rejoignez nous pour découvrir comment nous sommes passés d’une app pensée pour la France à une app prête à être utilisée dans le monde entier.

Nous verrons entre autre comment gérer intelligemment les devises, traductions, timezones/dates et distances, ou encore comment activer ou non des fonctionnalités en fonction de la location des utilisateurs

Avatar for Yann Vaillant

Yann Vaillant

April 24, 2019
Tweet

Other Decks in Programming

Transcript

  1. Hardcoded goodness_ public static TimeZone getParisTz() { TimeZone tz =

    TimeZone.getTimeZone("Europe/Paris"); if (tz.getRawOffset() == 0) { tz = TimeZone.getTimeZone("Europe/Brussels"); } if (tz.getRawOffset() == 0) { tz = TimeZone.getTimeZone("Europe/Berlin"); } if (tz.getRawOffset() == 0) { tz = TimeZone.getTimeZone("Europe/Amsterdam"); } if (tz.getRawOffset() == 0) { tz = TimeZone.getTimeZone("MET"); } if (tz.getRawOffset() == 0) { if (TimeZone.getDefault().inDaylightTime(new Date())) { tz = TimeZone.getTimeZone("GMT+2"); } else { tz = TimeZone.getTimeZone("GMT+1"); } } return tz; }
  2. Relax formatting // 11/04/1991 fun Calendar.formatShortDate(context: Context) = DateFormat.getDateFormat(context).format(time) //

    Apr 11, 1991 fun Calendar.formatMediumDate(context: Context) = DateFormat.getMediumDateFormat(context).format(time) // Monday, April 11, 1991 fun Calendar.formatLongDate(context: Context) = DateFormat.getLongDateFormat(context).format(time)
  3. Java Old Date/Calendar API TimeZone.getTimeZone("Europe/Paris") // * @param year the

    year minus 1900. // * @param month the month between 0-11. public Date(int year, int month, int date)
  4. Traduction_ <string-array name="numbers"> <item>one</item> <item>two</item> </string-array> <plurals name="number_of_rides_available"> <item quantity="one">%d

    ride</item> <item quantity="other">%d rides</item> </plurals> <string name="welcome"> Hello, %1$s! You have %2$d new messages. </string>
  5. Traduction_ <plurals name="number_of_rides_available"> <item quantity="one">{{number_of_ride}} ride</item> <item quantity="other">{{number_of_ride}} rides</item> </plurals>

    <string name="welcome"> Hello, {{name}}! You have {{number_of_messages}} new messages. </string> Format non explicite
  6. Traduction_ Localized.Plural(R.plurals.number_of_rides_available, it.rideNumber) Localized.String( R.string.welcome, subs = mapOf( "name" to

    userName, "number_of_messages" to numberOfMessages ) ) // Call format from your view to get a formatted string // from a Localized instance. val formattedString = context.format(Localized) Format non explicite
  7. Traduction_ desc "Pull translations and open a PR on Github"

    lane :translations_pr do git_checkout(branch_name: "master") git_checkout( branch_name: "Pull-translations-#{SecureRandom.hex(5)}", create?: true ) pull_translations git_commit(path: ["*/strings.xml"]) git_push(upstream_branch: new_branch_name) create_pull_request() slack(message: "New translations PR :earth_asia:") end Automatisation
  8. Conclusion Utilisez un outil de traduction Parlez toujours en UTC

    Utilisez le SDK ou un outil maison Rendez votre app configurable