Drupalcamp Atlanta 2010 Internationalization Presentation

39
Getting Started with Drupal Translations By Steven Jackson and Trent Wyman Mediacurrent Consultants Drupalcamp Atlanta 2010 October 2, 2010

description

Drupal Internationalization / Multi-Language presentation for Drupalcamp Atlanta 2010. Presented by Steven Jackson and Trent Wyman.

Transcript of Drupalcamp Atlanta 2010 Internationalization Presentation

Page 1: Drupalcamp Atlanta 2010 Internationalization Presentation

Getting Started withDrupal Translations

By Steven Jacksonand Trent Wyman

Mediacurrent Consultants

Drupalcamp Atlanta 2010October 2, 2010

Page 2: Drupalcamp Atlanta 2010 Internationalization Presentation

Overview

• This presentation will cover the basic steps for setting up a multi-lingual site in Drupal

• Discuss contrib modules needed• Cover basic configurations for content type

language support• Lessons learned from past projects

(Do’s & Don’ts)

`

Page 3: Drupalcamp Atlanta 2010 Internationalization Presentation

Introduction / BackgroundTrent Wyman

Occupation:

- Drupal Developer &Theming ConsultantDrupal Experience:

- Began experimenting with Drupal in version 4.7

- Employed as a full-time Drupal Developer & Theming Consultant since version 5

Company:

- Mediacurrent (www.mediacurrent.com)About Mediacurrent:

- Web development firm located in Alpharetta, GA

- Focused solely on Drupal Development, customization, & consultation

`

Page 4: Drupalcamp Atlanta 2010 Internationalization Presentation

Multi-Language Contrib Modules

Download the following contrib modules:• Internationalization Package (i18n)

- http://drupal.org/project/i18n• i18n Auto Translate

- http://drupal.org/project/i18n_auto• Language Switcher Dropdown (optional)

- http://drupal.org/project/lang_dropdown

`

Page 5: Drupalcamp Atlanta 2010 Internationalization Presentation

Enable Drupal Core Modules

Go to the modules list page in Drupal admin and enable the following modules under the “Core – optional” section:

1) Locale

2) Content Translations

www.yoursite.com/admin/build/modules

`

Page 6: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/build/modules

`

Page 7: Drupalcamp Atlanta 2010 Internationalization Presentation

Install Contrib Modules

Install the i18n, i18 Auto Translate, & Language Switcher Dropdown modules into your site’s modules folder.

www.yoursite.com\sites\all\modules\contrib\

`

Page 8: Drupalcamp Atlanta 2010 Internationalization Presentation

Get Your Language Template(s)

1) Choose & download the language(s) you want your site translated into. (http://drupal.org/project/Translations)

2) Unpack the .tar file(s) and install into the i18n/translations contrib module folder.

(sites\all\modules\contrib\i18n\translations)

`

Page 9: Drupalcamp Atlanta 2010 Internationalization Presentation

Enable Contrib Moduleswww.yoursite.com/admin/build/modules (“Multilanguage”)1) Auto draft translation

2) Block translation

3) CCK translation (if using custom CCK fields and fieldgroups)

4) Content type translation

5) Internationalization

6) Language switcher dropdown (if you prefer a dropdown selector v/s Locale’s text links)

7) Menu translation

8) Poll aggregate (if translating polls)

9) Profile translate (if translating user profiles)

10) String translation

11) Synchronize translations

12) Taxonomy translation

13) Views translation

`

Page 10: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/build/modules

`

Page 11: Drupalcamp Atlanta 2010 Internationalization Presentation

Configure Installed Language(s)

Go to the Languages Settings page in Drupal admin and select the “Configure” tab.

Then, under the “Language negotiation” subtab choose the “Path prefix only” option.

www.yoursite.com/admin/settings/language

`

Page 12: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/settings/language

`

Page 13: Drupalcamp Atlanta 2010 Internationalization Presentation

Enable Installed Language(s)

Now, select the “List” tab on the Languages Settings page and enable the languages you installed.

Here, you can also set your site’s default language (if other than English).

www.yoursite.com/admin/settings/language

`

Page 14: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/settings/language

`

Page 15: Drupalcamp Atlanta 2010 Internationalization Presentation

Enable Language SwitcherGo to the Blocks admin page and enable the language switcher under the “Disabled” section by assigning the block to your preferred Region.

Choose “Language switcher” if only using Locale (core).

Choose “Language switcher dropdown” if using the dropdown module (contrib).

www.yoursite.com/admin/build/block

`

Page 16: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/build/block

`

Page 17: Drupalcamp Atlanta 2010 Internationalization Presentation

Translating Your Site’s Content

Go to the “Content types” list page and select the content types that you want translated.

Click the “edit” link corresponding to the content type.

www.yoursite.com/admin/content/types

`

Page 18: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/content/types

`

Page 19: Drupalcamp Atlanta 2010 Internationalization Presentation

Translating Your Site’s Content

Next, on the content type’s “Edit” page refer to the “Workflow” section and choose “Enabled with translation”.

Then click the “Save” button at the bottom of the “Edit” page.

Example path:

www.yoursite.com/admin/content/node-type/blog

`

Page 20: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/admin/content/node-type/blog

`

Page 21: Drupalcamp Atlanta 2010 Internationalization Presentation

Create New ContentNow you can create and translate new content for the content type you enabled for multi-language support.

Go to the “Create Content” page, select the content type and then choose “English” (or your default language) from the “Language” dropdown selector.

Example path:

www.yoursite.com/node/add/blog

`

Page 22: Drupalcamp Atlanta 2010 Internationalization Presentation

www.yoursite.com/node/add/blog

`

Page 23: Drupalcamp Atlanta 2010 Internationalization Presentation

Translate New ContentAfter choosing the desired language from the “Language” selector, save the node.

Once you have saved the node, click the “Translate” tab located below the content’s title.

If this is new content, translations will already be available.

`

Page 24: Drupalcamp Atlanta 2010 Internationalization Presentation

Example path:www.yoursite.com/node/767/translate

`

Page 25: Drupalcamp Atlanta 2010 Internationalization Presentation

Translate Pre-existing Content

Translations in Drupal are not retro-active.

For content that existed before you enabled translations you will need to manually translate those nodes.

Click the “Add translation” link next to the desired language. Manually insert your translations into the “Title”, “Body”, etc. fields and save the node.

`

Page 26: Drupalcamp Atlanta 2010 Internationalization Presentation

Example path:www.yoursite.com/node/56/translate

`

Page 27: Drupalcamp Atlanta 2010 Internationalization Presentation

Switching Between Translations

Once you have your content translated, your users will be able to toggle between the languages by selecting the language links available in your “Language Selector” block (displayed within the Region you assigned on the Blocks admin page).

Example of language selector in Header Region:

`

Page 28: Drupalcamp Atlanta 2010 Internationalization Presentation

Translating Menus & Menu Items

Due to limited time I will not go into menu translations for this presentation.

For info on how to translate menus and menu items you can refer to the following online tutorials:

http://drupal-translation.com/content/adding-menu

http://becircle.com/translating_menus_drupal_6

http://drupal.org/node/275705

`

Page 29: Drupalcamp Atlanta 2010 Internationalization Presentation

Introduction / Background

Steven JacksonOccupation:

- Drupal ConsultantDrupal Experience:

- Mainly backend module development

- Server deployment

`

Page 30: Drupalcamp Atlanta 2010 Internationalization Presentation

How to make it work, 1• Start with a plan

– Start with using i18n– Don’t do it as an afterthought– Know what languages you are using

• Try to keep as much in Drupal – hardcode as little as necessary

`

Page 31: Drupalcamp Atlanta 2010 Internationalization Presentation

How to make it work, 2• Put what you can in the node• Translate interface is good but may be

cumbersome to search– Might have duplicate or similar text but in different

locations

• If doing after the fact, make node_clone your friend

`

Page 32: Drupalcamp Atlanta 2010 Internationalization Presentation

How to make it work, 3

• If a social site, setup content_profile– Can then translate profile content in same

manner

• Coordinate with someone who knows the languages

`

Page 33: Drupalcamp Atlanta 2010 Internationalization Presentation

How to make it break• == !previousSlides

– Don’t plan ahead, buy lots of Tylenol

• Don’t wrap module text in t()• Write output in direct PHP instead of via Drupal

`

Page 34: Drupalcamp Atlanta 2010 Internationalization Presentation

What can go wrong• Server not rendering special characters• Pathauto, url_alias may create new path when

saving node after initial creation– Have to go into db and clear aliases and auto urls for

content

– Get a lot of some-path-name-0

`

Page 35: Drupalcamp Atlanta 2010 Internationalization Presentation

How fix what you break, 1• IF PHP

– You’ll want to parse the URL to get language or get $language->language

– if/switch language to output correct language text– Make friends with regex, might have to output some

special characters that some PHP functions aren’t generating (like date())

`

Page 36: Drupalcamp Atlanta 2010 Internationalization Presentation

How fix what you break, 2• IF PATHAUTO, URL_ALIAS

– Often ran into new url being generated when merely updating content

– Go into db, remove path_auto, url alias associations– Reassociate nodes via the translate tab

`

Page 37: Drupalcamp Atlanta 2010 Internationalization Presentation

Pros / Cons• Pros

– Well, you have a multilingual site– Only had to setup one code base

• Cons– If not planning ahead can be a headache– Might feel like you created multiple sites

despite auto generation

`

Page 38: Drupalcamp Atlanta 2010 Internationalization Presentation

Things to Remember• Setup translation auto-generation• If doing after the fact, setup translation

associations• Setup each view to be based on user’s current

language in filters

`

Page 39: Drupalcamp Atlanta 2010 Internationalization Presentation

Questions / Comments?

`