here comes localize.drupal.org!

75
Here comes localize.drupal.org Gábor Hojtsy, Acquia, Drupalcon Paris

Upload: gabor-hojtsy

Post on 14-Dec-2014

1.028 views

Category:

Technology


0 download

DESCRIPTION

Here comes localize.drupal.org slides from Drupalcon Paris, 2009.

TRANSCRIPT

Page 1: Here comes localize.drupal.org!

Here comes localize.drupal.orgGábor Hojtsy, Acquia, Drupalcon Paris

Page 2: Here comes localize.drupal.org!

ME

• Needed a translated Drupal in 2003

• Became locale.module maintainer, Drupal 6 core committer

• Developed all kinds of translation tools

• Working for Acquia

Page 3: Here comes localize.drupal.org!

YOU

• Running translated Drupal sites?

• Translating modules for “self”?

• Contributing to drupal.org translations?

• Writing & translating modules to “self”?

Page 4: Here comes localize.drupal.org!

Take a walk

Page 5: Here comes localize.drupal.org!

2001 Jan 22t() is born

2001 Feblocale.module,

translation interface

2.0.0 3.0.01.0.0

Drupal

Drupal.org

Disclaimer: time scale not exact

Page 6: Here comes localize.drupal.org!

2002 JanLocale cache

2003 Sepextractor.php

2004 AugGettext based sharing,

web admin, plurals

4.0.0 4.3.0 4.7.04.5.0

Disclaimer: time scale not exact

Page 7: Here comes localize.drupal.org!

2006 Aug@ !

2006 SepTranslatable installer

2007 MayAutomated import

5.0

Disclaimer: time scale not exact

Page 8: Here comes localize.drupal.org!

2007 JunJS translation

6.0

2009 Auglocalize.drupal.org

2007 JunJS translation

2009 JunContexts

Disclaimer: time scale not exact

7.0

Page 9: Here comes localize.drupal.org!

All lined up

Page 10: Here comes localize.drupal.org!

TRANSLATINGTHE BUILT-IN

INTERFACE

Page 11: Here comes localize.drupal.org!

TEXT COMESFROM

SOURCE CODE

Page 12: Here comes localize.drupal.org!

t(‘Go to %page’, array(‘%page’ => $p));

Drupal.t(‘Go to %page’, {‘%page’: num});

Page 13: Here comes localize.drupal.org!

format_plural( $count, ‘1 year’, ‘@count years’);

Drupal.formatPlural( count, ‘1 year’, ‘@count years’);

Page 14: Here comes localize.drupal.org!

D!"#$% 6

&!$'(%$&)*

' +,-$& (,--& .

1.1

- '*.-/0-!

15

. 20

07

.

Core PHP translation API

t(‘Home’)Translates ‘Home’ to the

requested language.

format_plural

($count,

‘1 comment’,

‘@count comments’)

Returns the proper

translation for the text based

on plural rules in the

requested language.

Optional variable replacements array and

language code can be provided in this order.

JavaScript translation API

Drupal.t(‘Home’)Translates ‘Home’ to the

language used for page display.

Drupal.formatPlural

(count,

‘1 comment’,

‘@count comments’)

Returns the proper translation for

the text based on plural rules in

the page’s language.

Optional variable replacements array can be provided,

language is always the page language!

Replacement formats (based on prefix characters)

@countReplaced with the value escaped with

check_plain() for output.

%size

Replaced with the value escaped and

formatted as a placeholder (theme

(‘placeholder’)).

!htmlReplaced with the value as is, without

any additional formatting. Insecure! Only

use if you already sanitized your text.

Example: t(‘%name moved to @directory’, array(

‘%name’ => $filename, ‘@directory’ => $dirname);

Other PHP functions using translation features

format_date

($timestamp,

'medium', ...)

Translates parts of the

date/time formatting.

format_interval

($timestamp, ...)

Displays the time interval in

human terms. Translates

names of the segments.

format_size($size, ...)

Formats a file size provided

in bytes. Translates the MB,

KB and byte labels.

All functions accept an optional language code at the end.

Text extracted for translation and used later

.info filesModule/theme name;

description; package name.

hook_perm()

implementations

Literal permission names,

when provided with standard

array syntax.

hook_menu()

implementations

Menu item ‘title’ and

‘description’ keys, when

provided as literal strings.

watchdog(‘menu’,

‘Items saved’) calls

Log type and message,

when provided as literal

strings. Third parameter

specifies the replacements

array. No plural support.

Translating text in the installer

st(‘Home’)

Works the same way as t(), but

uses a file+memory backend. Use

only in the installer and in install

profiles. No plural support.

$t = get_t();

$t(‘Home’);

Use get_t() in .install files and any

other code which could run in the

installer too. It returns ‘t’ or ‘st’

depending on the function to be

used at the moment.

Remember: if you have an .install file and need to use translation, your

function calls could easily end up running in the installer if your module

becomes a core module in an install profile. Use get_t()!

Tools to verify you are using the API properly

http://drupal.org/project/potx

Drupal 6.x-2 or later versions have coder module plugin support, so

improper use of the API is reported in reviews. Also feel free to export a

template for your module/theme and check whether all strings appear.

http://drupal.org/project/l10n_client

The potx module cannot find mistakes when you forgot to use t() or some

other function to translate your output. The localization client has a

convenient interface to translate text displayed on the page. If certain

strings are not showing up for translation, you forgot to use the API.

The most common mistakes

Using dynamic values, such as t($type).

Whenever you use dynamic strings to call

the above functions, make sure that all

possible values are already in the code

elsewhere in literal form using the API.

Do not translate user provided content.

Reuse of the same message eg. for

watchdog() and drupal_set_message()

calls. The former disallows t(), the later

requires t(), so this is not possible.

Always call the above API functions

directly, without indirection.

Usage of t() in a global context,

such as define(‘CONST’, t(‘...’)). The

locale system is not yet initialized at

that time, so this usage is incorrect

and also leads to nasty performance

problems. Never do it.

By Gá

bor Hojtsy – C

heck for new versions at hojtsy.hu – F

reely redistributable as long as credit is kept.

GET THE CHEAT SHEET

FROMHOJTSY.HU

ALSO SEED.O/NODE/322729

Page 15: Here comes localize.drupal.org!

TEXT IS FOUND AND REPLACED

RUNTIME, WHEN USED

Page 16: Here comes localize.drupal.org!

Hungarian Croatian

Go to %page %page. oldalra ugrás ...

1 year 1 év

@count years @count év

Uhm, not so simple

Page 17: Here comes localize.drupal.org!

TRANSLATIONSARE STORED

IN THE DATABASE

Page 18: Here comes localize.drupal.org!

DRUPAL PROCESS

Runningsource code

Page 19: Here comes localize.drupal.org!

DRUPAL PROCESS

Runningsource code

Found text stored in DB

Page 20: Here comes localize.drupal.org!

DRUPAL PROCESS

Runningsource code

Found text stored in DB

User interfaceto translate text,

stored in DB

Page 21: Here comes localize.drupal.org!

DRUPAL PROCESS

Runningsource code

Found text stored in DB

User interfaceto translate text,

stored in DB

Text replaced on output

Page 22: Here comes localize.drupal.org!

Where’s the happy family?

Page 23: Here comes localize.drupal.org!

TRANSLATIONSARE SHARED

IN GETTEXT .PO

Page 24: Here comes localize.drupal.org!

SHARING PROCESS

Page 25: Here comes localize.drupal.org!

SHARING PROCESS

Page 26: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Page 27: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Page 28: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Page 29: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 30: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 31: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 32: Here comes localize.drupal.org!

Staticsource code

Gettext .pot

•Translation template extractor

•http://drupal.org/project/potx

•Web interface in your Drupal install

•Interfaces with coder review module to help developers

Page 33: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 34: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 35: Here comes localize.drupal.org!

Gettext .pot

Translated .po

Desktop tools like PoEdit or just Notepad

Page 36: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 37: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 38: Here comes localize.drupal.org!

Translated .po

•Translation teams commit .po files to CVS

•http://drupal.org/project/Translations and under contributed projects

•Released on the parent project’s timeframe

•Drupal imports automatically

Page 39: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 40: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 41: Here comes localize.drupal.org!

•Built-in translation interface

•http://drupal.org/project/l10n_client

•Import and export .po(t) files manually

Page 42: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 43: Here comes localize.drupal.org!

SHARING PROCESSStatic

source code

Gettext .pot

Translated .po

Page 44: Here comes localize.drupal.org!

All come together

Page 45: Here comes localize.drupal.org!

GIVING AWAY(THIS WAY)

IS HARD

Page 46: Here comes localize.drupal.org!
Page 47: Here comes localize.drupal.org!

POTX

Page 48: Here comes localize.drupal.org!

.POPOTX

Page 49: Here comes localize.drupal.org!

CVS.POPOTX

Page 50: Here comes localize.drupal.org!

CVS.POPOTX

RELEASES

Page 51: Here comes localize.drupal.org!

CVS

BRANCHES

.POPOTX

RELEASES

Page 52: Here comes localize.drupal.org!

CVS

BRANCHES

.PO

PLURAL FORMS

POTX

RELEASES

Page 53: Here comes localize.drupal.org!

CVS

BRANCHES

.PO

SCHEDULING

PLURAL FORMS

POTX

RELEASES

Page 54: Here comes localize.drupal.org!

CVS

BRANCHES

.PO

SCHEDULING

PLURAL FORMS

POTX

RELEASES

ISSUE QUEUES

Page 55: Here comes localize.drupal.org!

ENOUGH!

Page 56: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Web UI for Drupal.org project translations

Page 57: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Automated parsing of Drupal.org releases on

publication

Page 58: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Skips CVS, branching, templates, hides potx and

plural forms, does not require desktop tools

Page 59: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Single-sign-on with Drupal.org

Page 60: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Organic groups based translations

Page 61: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Different permission levels (open/controlled)

Page 62: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Keeps import/export support with Gettext

formats

Page 63: Here comes localize.drupal.org!

LOCALIZE.DRUPAL.ORG

Provides a remote submission web service for

Localization client

Page 64: Here comes localize.drupal.org!

Oh, those stats!

Page 65: Here comes localize.drupal.org!

almost

5000projects known

over

5600releases parsed

over

149000strings to translate

Page 66: Here comes localize.drupal.org!

149000IT IS LIKE

TRANSLATING DRUPAL43 TIMES

Page 67: Here comes localize.drupal.org!

TRANSLATION TEAMS LAUNCHED

IN BETA(MORE IN QUEUE)

15

Page 68: Here comes localize.drupal.org!

Take a ride!

Page 69: Here comes localize.drupal.org!

Envious?

Page 70: Here comes localize.drupal.org!

SOFTWARE ON L.D.O

• Translation template extractorhttp://drupal.org/project/potx

• Localization server:http://drupal.org/project/l10n_server

• Organic groupshttp://drupal.org/project/og

Page 71: Here comes localize.drupal.org!

TRANSLATE YOUR CODE

• Open Atrium and Gallery 2 uses Localization server to translate their code

• You can set up l10n_server to parse your own code and translate in-house

• Eg. https://translate.openatrium.com/

Page 72: Here comes localize.drupal.org!

Long way to go

Page 73: Here comes localize.drupal.org!

Color the future!

Page 74: Here comes localize.drupal.org!

THESE SLIDES ARE (CC)

This presentation is © Gábor HojtsyLicensed: http://creativecommons.org/licenses/by-nc-sa/2.0/

Photo credits:http://www.flickr.com/photos/sinkdd/2853334715/

http://www.flickr.com/photos/chavals/2978360981/

http://www.flickr.com/photos/koesbong/125933266/

http://www.flickr.com/photos/cheishichiyo/3637712921/

http://www.flickr.com/photos/paky/52194393/

http://www.flickr.com/photos/patrickgage/3738107746/

http://www.flickr.com/photos/zhzheka/1240470939/

http://www.flickr.com/photos/fchouse/3270958643/

http://www.flickr.com/photos/colinj/490622069/

http://www.flickr.com/photos/brartist/313272029/