Slide 1

Slide 1 text

How translations work in WordPress Dominik Schilling @ocean90

Slide 2

Slide 2 text

Or: One guy tries to explain a system which makes WordPress for ~50% of its user base available in their native language. Dominik Schilling @ocean90

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Dashboard

Slide 8

Slide 8 text

$title = __( 'Dashboard' ); wp-admin/index.php:31 gettext Functions

Slide 9

Slide 9 text

MakePOT https://i18n.trac.wordpress.org/log/pot

Slide 10

Slide 10 text

#: wp-admin/index.php:31 msgid "Dashboard" msgstr "" Portable Object Template (POT)

Slide 11

Slide 11 text

#: wp-includes/admin-bar.php:743 msgid "%s comment awaiting moderation" msgid_plural "%s comments awaiting moderation" msgstr[0] "" msgstr[1] "" Portable Object Template (POT)

Slide 12

Slide 12 text

MakePOT • CLI tool for PHP to create POT files for • WordPress Core • Plugins • Themes • WordPress.org projects • Open source: https://github.com/ocean90/wp-i18n-tools/blob/master/makepot.php • Similar to Poedit but supports additional header fields for plugins and themes

Slide 13

Slide 13 text

MakePOT $ crontab -l | grep generate-pot 10 * * * * /bin/sh /home/wporg/bin/generate-pot.sh wp /home/wporg/co 25 * * * * /bin/sh /home/wporg/bin/generate-pot.sh wpthemes /home/wporg/co 30 * * * * /bin/sh /home/wporg/bin/generate-pot.sh wporg /home/wporg/co 40 * * * * /bin/sh /home/wporg/bin/generate-pot.sh rosetta /home/wporg/co 50 * * * * /bin/sh /home/wporg/bin/generate-pot.sh wordcamporg /home/wporg/co • Runs on a cron job every hour • Custom wrapper generate-pot.sh • Updates SVN checkouts • Commits POT files to i18n.svn.wordpress.org

Slide 14

Slide 14 text

How can I translate the POT file?

Slide 15

Slide 15 text

GlotPress

Slide 16

Slide 16 text

GlotPress • Since January 18, 2016 a WordPress Plugin • https://wordpress.org/plugins/glotpress/ • Lets you set up your own collaborative, web-based software translation tool • Previously powered by the deprecated BackPress library • 33 contributors • Leads: Nikolay Bachiyski, Marko Heijnen, Greg Ross, Dominik Schilling • Developed on GitHub: https://github.com/GlotPress/GlotPress-WP

Slide 17

Slide 17 text

translate.wordpress.org

Slide 18

Slide 18 text

translate.wordpress.org

Slide 19

Slide 19 text

translate.wordpress.org

Slide 20

Slide 20 text

Import of POT files $ crontab -l | grep update-originals 59 * * * * /bin/sh /home/wporg/bin/update-originals-wp.sh /home/wporg/co /home/ wporg/public_html/wp-content/plugins/glotpress • Importer runs on a cron job every hour • Wrapper for GlotPress’ default CLI importer • Slack notification in #polyglots channel

Slide 21

Slide 21 text

translate.wordpress.org

Slide 22

Slide 22 text

Language Packs ary.mo ary.po admin-ary.mo admin-ary.po admin-network-ary.mo admin-network-ary.po continents-cities-ary.mo continents-cities-ary.po • Export of translations in a ZIP file • Updated every 24 hours

Slide 23

Slide 23 text

.po - Portable Object # Translation of 4.6.x in Moroccan Arabic # This file is distributed under the same license as the 4.6.x package. msgid "" msgstr "" "PO-Revision-Date: 2016-09-21 10:19:10+0000\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" "X-Generator: GlotPress/2.1.0-alpha\n" "Project-Id-Version: 4.6.x\n" #: wp-includes/admin-bar.php:334 wp-includes/admin-bar.php:414 #: wp-includes/admin-bar.php:481 wp-includes/deprecated.php:2792 #: wp-includes/deprecated.php:2794 msgid "Dashboard" msgstr "ﺔﯿﺴﯿﺋﺮﻟا"

Slide 24

Slide 24 text

.mo - Machine Object de12 0495 0000 0000 0200 0000 1c00 0000 2c00 0000 0500 0000 3c00 0000 0000 0000 5000 0000 0900 0000 5100 0000 4001 0000 5b00 0000 1000 0000 9c01 0000 0100 0000 0000 0000 0000 0000 0000 0000 0200 0000 0044 6173 6862 6f61 7264 0050 4f2d 5265 7669 7369 6f6e 2d44 6174 653a 2032 3031 362d 3039 2d32 3120 3130 3a31 393a 3130 2b30 3030 300a 4d49 4d45 2d56 6572 7369 6f6e 3a20 312e 300a 436f 6e74 656e 742d 5479 7065 3a20 7465 7874 2f70 6c61 696e 3b20 6368 6172 7365 743d 5554 462d 380a 436f 6e74 656e 742d 5472 616e 7366 6572 2d45 6e63 6f64 696e 673a 2038 6269 740a 506c 7572 616c 2d46 6f72 6d73 3a20 6e70 6c75 7261 6c73 3d36 3b20 706c 7572 616c 3d6e 3d3d 3020 3f20 3020 3a20 6e3d 3d31 203f 2031 203a 206e 3d3d 3220 3f20 3220 3a20 6e25 3130 303e 3d33 2026 2620 6e25 3130 303c 3d31 3020 3f20 3320 3a20 6e25 3130 303e 3d31 3120 2626 206e 2531 3030 3c3d 3939 203f 2034 203a 2035 3b0a 582d 4765 6e65 7261 746f 723a 2047 6c6f 7450 7265 7373 2f32 2e31 2e30 2d61 6c70 6861 0a50 726f 6a65 6374 2d49 642d 5665 7273 696f 6e3a 2034 2e36 2e78 0a00 d8a7 d984 d8b1 d8a6 d98a d8b3 d98a d8a9 00

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

WordPress Translation API

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

WordPress ❤ Language Packs • Translations are stored in wp-content/languages • Translations are auto-updated • Translations are installed on-the-fly when switching your site language • Translations are installed asynchronously during other updates

Slide 29

Slide 29 text

load_default_textdomain() https://developer.wordpress.org/reference/functions/ load_default_textdomain/ Core Translation API

Slide 30

Slide 30 text

$title = __( 'Dashboard' ); wp-admin/index.php:31 gettext Functions

Slide 31

Slide 31 text

Are language packs for plugins and themes a thing?

Slide 32

Slide 32 text

YES. And they work more or less the same as core’s.

Slide 33

Slide 33 text

Requirements • The plugin/theme uses a proper text domain registration • Text domain is the same as the plugin/theme slug • Exception for WordPress 4.6+ • The plugin/theme is hosted in the official WordPress directory • Nothing more.

Slide 34

Slide 34 text

Good to know • Follow the #meta-language-packs channel on Slack • Language packs are updated 30 minutes after a change • Languages packs are generated if a project is 95% or more translated

Slide 35

Slide 35 text

Good to know • Check the status by visiting the Language Packs page of your project on translate.wordpress.org

Slide 36

Slide 36 text

Who likes to see some numbers?

Slide 37

Slide 37 text

164 locales

Slide 38

Slide 38 text

1 466 editors

Slide 39

Slide 39 text

17 635 translators

Slide 40

Slide 40 text

50 609 projects

Slide 41

Slide 41 text

0 5000000 10000000 15000000 20000000 25000000 30000000 2010 2011 2012 2013 2014 2015 2016 605681 708589 901790 1233869 1692593 21674064 9586107

Slide 42

Slide 42 text

36 402 519 current translations

Slide 43

Slide 43 text

34 774 language packs

Slide 44

Slide 44 text

1 046 554 284 downloads of language packs

Slide 45

Slide 45 text

The Future

Slide 46

Slide 46 text

GlotPress • x+1 (now): Locale glossaries, JavaScript Localization • x+2: Notes/Comments/Reject with feedback, Notifications • x+3: REST API • x+4: Theme/Templates/Design • x+5: Translation Memory

Slide 47

Slide 47 text

Language Packs • Faster updates, just like for plugins/themes • Reduce the number of complex packages • my_MM, ja , far_IR, hu_HU, sr_RS, zh_CN • Make automatic release builds more … automatic • Move readme.html to translate.wordpress.org • No SVN

Slide 48

Slide 48 text

Q&A Dominik Schilling @ocean90