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

Creating Multilingual Websites in WordPress

Shawn Hooper
December 01, 2017

Creating Multilingual Websites in WordPress

Shawn Hooper

December 01, 2017
Tweet

More Decks by Shawn Hooper

Other Decks in Technology

Transcript

  1. 
 Director of IT @ Actionable.co
 & Freelance WordPress Developer


    Co-Organizer, WordCamp Ottawa
 Core Contributor
 
 
 Bilingual (Je parle français) Hi, I’m Shawn! @shawnhooper shawnhooper.ca
  2. “The method of human communication, either spoken or written, consisting

    of the use of words in a structured and conventional way” - Oxford Dictionary 
 Examples: English, French
 Spanish, Italian Language @shawnhooper shawnhooper.ca
  3. A locale is a set of parameters that defines the

    user's language, region and any special variant preferences that the user wants to see in their user interface. 
 
 A locale identifier consists of at least a language identifier and a region identifier. - Wikipedia Locale @shawnhooper shawnhooper.ca
  4. Canadian English
 en-CA US English
 en-US Canadian French 
 fr-CA

    Argentina Spanish 
 es-AR Spanish Columbia 
 es-CO Locale @shawnhooper shawnhooper.ca
  5. 
 
 The process of planning and implementing products and

    services so that they can easily be adapted to specific local languages and culture. i18n Internationalization @shawnhooper shawnhooper.ca
  6. 
 The process of adapting a product or content to

    a specific locale or market. L10n Localization @shawnhooper shawnhooper.ca
  7. Localization isn’t just about words, think about: CURRENCY
 English $1,234.56


    French 1 234,56 $ Considerations… @shawnhooper shawnhooper.ca
  8. Localization isn’t just about words, think about: DATES
 English (US)

    MM/DD/YYY (ex: 03/20/2016) English (Canada) DD/MM/YYYY (ex: 20/03/2016) Considerations… @shawnhooper shawnhooper.ca
  9. Localization isn’t just about words, think about: TIME
 English (Canada)

    4:30 pm French (Canada) 16h30 Considerations… @shawnhooper shawnhooper.ca
  10. Gender 
 “While modern English grammar is exceptionally capable of

    being gender neutral, many other languages do not share this trait.”
 
 - yoavf
 
 https://core.trac.wordpress.org/ticket/42725 Considerations… @shawnhooper shawnhooper.ca
  11. Localization isn’t just about words, think about: Script Direction Considerations…

    Left to Right Right to Left English Arabic Spanish Persian French Hebrew Greek Yiddish Latin Western Punjabi @shawnhooper shawnhooper.ca
  12. How do you want your URLs structured? 
 
 


    example.com/?lang=es
 
 example.com/en
 
 jp.example.com
 
 mywebsite.com vs. monsiteweb.com 
 
 Considerations… @shawnhooper shawnhooper.ca
  13. How do you want to switch languages?
 
 
 Dropdown

    Menu
 
 Widget Area
 
 What if no translation is available for a specific post?
 
 What about Query String Parameters? Considerations… @shawnhooper shawnhooper.ca
  14. WordPress Core is translated in 110 locales. 53 translations are

    100% complete, up-to- date with the most current version of WordPress. 50.788% of WordPress sites are running a translated version. WordPress @shawnhooper shawnhooper.ca
  15. Although WordPress comes in many languages, it does not natively

    support providing viewers with content in more than one language. @shawnhooper shawnhooper.ca
  16. WPML Premium Plugin from OnTheGoSystems. https://wpml.org/ Supports: Posts
 Pages
 Custom

    Post Types
 Taxonomies
 Menus
 Theme Text
 Plugin Text @shawnhooper shawnhooper.ca
  17. Tip: Turn off the Make Themes Work Multilingual option if

    you don’t need it! @shawnhooper shawnhooper.ca
  18. qTranslate X Free Plugin Available on WordPress.org Supports: Posts
 Pages


    Custom Post Types
 Taxonomies
 Menus
 General Settings
 Widgets @shawnhooper shawnhooper.ca
  19. If you disable the plugin, you’ll see
 the content for

    each language is wrapped in shortcodes. Shortcode Warning @shawnhooper shawnhooper.ca
  20. Polylang Free Plugin in WordPress Repo + Premium “Polylang Pro”

    Supports: Posts
 Pages
 Media
 Taxonomies
 Menus
 Widgets @shawnhooper shawnhooper.ca
  21. There are two ways of doing this: Separate Installs of

    WordPress for each language (yuck!) Using WordPress Multisite with a sub-site for each language (yay!) Multisite Approach @shawnhooper shawnhooper.ca
  22. 
 Multisite Language Switcher
 or 
 MultilingualPress 
 plugins give

    you the ability link translations between the sites in a Multisite network Language Switching @shawnhooper shawnhooper.ca
  23. Comparison Feature WPML qTranslateX Polylang Multisite Cost Paid Free Freemium

    Free Content Storage Separate Posts Single Post Separate Posts Languages in Subsites Widget Areas Needs Additional Plugins Yes Yes Yes Media With Additional Plugin No Yes Each subsite has it’s own media library Permalink Translation Yes With “Qtranslate Slug” Plugin Pro Only Yes Sync Custom Fields Yes Yes Yes No Sync Taxonomies Yes Yes Yes No Translate Strings in Themes & Plugins WPML String Translation Plugin Additional Plugins Required Additional Plugins Required Additional Plugins Required Database Impact High Low Low Low Translation Service Support ICanLocalize No Additional Plugin No @shawnhooper shawnhooper.ca
  24. Internationalizing Themes & Plugins 
 
 In order for themes

    and plugins to work in multiple languages,
 they must be internationalized. 
 
 WordPress provides functions
 to retrieve strings in the right locale. @shawnhooper shawnhooper.ca
  25. Internationalizing Themes & Plugins 
 
 Instead of :
 


    <p>This is my string</p> @shawnhooper shawnhooper.ca
  26. Internationalizing Themes & Plugins 
 
 Use :
 
 <p><?php

    esc_html_e(‘This is my string’, ‘textdomain’);?></p> @shawnhooper shawnhooper.ca
  27. Internationalizing Themes & Plugins 
 For strings in JavaScript, use

    wp_localize_script() @shawnhooper shawnhooper.ca
  28. Internationalizing Themes & Plugins 
 For strings in JavaScript, use

    wp_localize_script() @shawnhooper shawnhooper.ca
  29. .POT, .PO and .MO Files 
 Contain all the strings

    in your plugins and themes for a specific language. .POT = Template ( Original Strings ) .PO = Localized Version of the Strings .MO = Machine Object files (compiled .PO files) @shawnhooper shawnhooper.ca
  30. .POT, .PO and .MO Files Many popular themes & plugins

    come with translations already provided. If not, you can manage your own translations through plugins or 3rd party applications. @shawnhooper shawnhooper.ca
  31. PO Edit Desktop Application for Managing POT and PO Files

    Freemium Available for Windows, OSX and Linux
 (poedit.net) @shawnhooper shawnhooper.ca
  32. Translation Services Built in Translation Services in WordPress: ICanLocalize (Works

    with WPML) LingoTek (Works with Polylang) @shawnhooper shawnhooper.ca
  33. Polyglots Team The polyglots team is responsible for ensuring WordPress

    is available in dozens of languages and many more regions. It’s a big job, which is why they need help from native speakers of many languages to make it possible. https://make.wordpress.org/polyglots/ @shawnhooper shawnhooper.ca