Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Getting WordPress to speak your langauge


Published on

Presentation slides from WordCamp Montreal 2012 talk.

An in-depth look at creating WordPress sites in a language other than English, and/or with multiple languages. We will: set up a WordPress site that is not English, see what is needed in themes and plugins to use them in other languages, and learn how to create translations for themes and plugins. We will then review the different strategies and options for creating multilingual sites, from simple sites with custom themes, to multilingual plugins and multisite installs, and the issues related to each approach.

Published in: Technology, Business
  • Be the first to comment

Getting WordPress to speak your langauge

  1. 1. hello bonjour guten tag Hola 你好 helló hej“Getting WordPress to hallo γειά σου speak your language” ciao sveiki halló cześć alo 안녕하세요 привіт hallåRick Radko WordCamp August 18th, 2012
  2. 2. A little bit about meRick Radko – R-Cubed Design Forge  Software, web and app designer/developer.  Creating web sites since 1996.  Artistic and creative engineer.  WordPress enthusiast.  Co-organizer of: The Ottawa WordPress Group. http://wpottawa.orgSlides are posted at: © 2012 Rick Radko, 1
  3. 3. About this talkThe objective of this talk is to provide a primer for theconcepts and resources needed to create WordPresssites in any language(s).To keep the talk non-technical for the user track (and toshorten it) I‟ve referenced links for the technical aspects,or moved them to the appendix rather than discussingthem in the talk.If you have technical questions after this talk you cancontact me at:© 2012 Rick Radko, 2
  4. 4. Fair warning!If you want to set-up a WordPress site in differentlanguages yourself, you will need:  to do WordPress installs.And depending on the configuration or complexityof your site, you may need to:  edit some configuration files.  edit/create language files.  edit/create theme files*All of this is well documented on the codex and elsewhere (useGoogle), and quite simple for basic sites.© 2012 Rick Radko, 3
  5. 5. noteIf you are a user:  You can easily set your blog to any one of over 50 languages with simple options see:  Except for the next section on translations, most of this talk does not apply to you want to do more with languages than youcan on, then stick around…© 2012 Rick Radko, 4
  6. 6. Lets get started!Translation:  The act of converting one language to another.  Tends to be the thing that concerns people the most when they consider a web site in another language.  You will need to get phrases, strings, and words translated, but:  That is relatively straight forward.  You don‟t even need to be able speak the language to create a site in that language, although it makes it easier.© 2012 Rick Radko, 5
  7. 7. Getting translations  Human translations a) Do it yourself (if you speak the languages) b) Hire a translator:  Good/best results.  Aware of regional differences, customs and dialects.  9-14 cents per word.  Machine translations:  Inconsistent results – some good, some bad.  Better than it was a few years ago.  Still not a good option for a business site.© 2012 Rick Radko, 6
  8. 8. Google TranslateYou can translate entire sites by entering a URL inGoogle Translate© 2012 Rick Radko, 7
  9. 9. French to English: the good This looks promising.© 2012 Rick Radko, 8
  10. 10. French to English: the bad But if we start looking more carefully…© 2012 Rick Radko, 9
  11. 11. French to English: the ugly A bit further down the page  The ideal speaker discuss a topic on WordPress really is passionate and for which he may present …© 2012 Rick Radko, 10
  12. 12. How about English to French?More translation issues…© 2012 Rick Radko, 11
  13. 13. Translation summaryFor professional results, use human translators: “Under the weather” won‟t become: “Beneath a turbulent sky”© 2012 Rick Radko, 12
  14. 14. Creating a website in another languageTo create a web site in another language:  It is obvious to most people that we need to translate our content, posts, pages, menu items, captions, and other content, and even possibly comments, to the languages wanted on the website.  What is not so obvious is that we need to translate WordPress.© 2012 Rick Radko, 13
  15. 15. Translating WordPressThe rest of this talk will be about translating orlocalizing WordPress.  In the first half we‟ll look at:  Concepts, terms and issues with localization.  Creating a single language site.  In the second half we will look at:  Creating multilingual sites.© 2012 Rick Radko, 14
  16. 16. Internationalization: The first step in localizationInternationalization  Is the process of designing software applications so that they can be adapted to various languages and regions without programming changes.  WordPress uses the GNU gettext libraries and tools for internationalization.  Programmers use gettext to produce a file with a list of words and strings that need translation.For more info see:© 2012 Rick Radko, 15
  17. 17. LocalizationLocalization  Is the process where translators adapt internationalized software to another language and culture by adding locale specific components and translating the text.  Localization does not require any changes to the application code. (programmers are not needed)For more info see:© 2012 Rick Radko, 16
  18. 18. LocaleA locale is a combination of language and regionaldialect.  Locales usually correspond to countries.  They are represented by codes.  Examples of locale codes:  fr-_CA would be for French and Canada.  en_ CA would be for English and Canada.For more info see:© 2012 Rick Radko, 17
  19. 19. Locale and WordPressWordPress, the themes, plugins and widgetsneed to know what language to use to displaythe site.  That is determined by the locale set in the wp-config.php file.  It‟s a bit of PHP code and looks like: define (WPLANG, „fr_FR);  If it‟s not set, or the matching language files don‟t exist, English will be used.© 2012 Rick Radko, 18
  20. 20. Some key items affected by localizationDate formats:  Is it 05/29/2012 or 29/05/2012?  May 29th, 2012 <-> Le 29 mai 2012Time display:  Is it 4:30pm or 16:30?Number formats:  Is it 1.987,06 or 1,987.06?© 2012 Rick Radko, 19
  21. 21. More: why localize WordPress?Separators, curly quotes, apostrophes anddashes:  All can have regional differences.Localizing sets the HTML language code for thesite:  Tells the browser, search engines and other readers the language that your content is written in.© 2012 Rick Radko, 20
  22. 22. 73 localizations ready and waitingFortunately most of us won‟t need to do the workof localizing WordPress:  Currently there are 73 translations of WordPress available.So how do you get these other languages?© 2012 Rick Radko, 21
  23. 23. Start with “WordPress in your language”Start with thecodex page:  WordPress in Your Language  This page documents the current translations for WordPress.© 2012 Rick Radko, 22
  24. 24. Find the language you wantThis is the French entry:Note: fr_FR is the locale for French from France.  There is no Canadian version.© 2012 Rick Radko, 23
  25. 25. Official site for the French WordPressOffers some general information and a downloadfor the French version of WordPress.© 2012 Rick Radko, 24
  26. 26. WordPress Francophone (the 4th link)Has more French WordPress support, includingforums (the 5th link).© 2012 Rick Radko, 25
  27. 27. Installable versions vs language filesThe majority of the languages listed on WordPressin Your Language have complete installableversions of WordPress.There are many however that have only thelanguage files needed to convert the defaultversion of WordPress to a new language.© 2012 Rick Radko, 26
  28. 28. Installable localizationsThe installable versions of WordPress are:  Easy to install.  Use the same “5 minute” install as the default WordPress.  Great for single language sites.  Could use as starting point for multilingual sites.  Often include translated sample content. (Hello world post, sample page, menus etc.)© 2012 Rick Radko, 27
  29. 29. Language file only localizationsLanguage file only localizations:  Do not have sample content.  Are a bit more technical to install.*See: “Creating your own translations” in the appendix for moreinformation on language files.© 2012 Rick Radko, 28
  30. 30. Installing the French versionGet the install file from‟s a full install file, so install as you would for aregular manual install of WordPress:  See:  Cannot use installers like SimpleScripts or Fantastico, on most North American hosting companies they will have the English version.© 2012 Rick Radko, 29
  31. 31. A fresh French WordPress installThe front page withthe usual “HelloWorld” post.The Twenty Eleventheme is thedefault.© 2012 Rick Radko, 30
  32. 32. French WordPress install – example pageThe example page.Everything on the sitelooks pretty muchlike the regularWordPress installexcept it‟s all French.© 2012 Rick Radko, 31
  33. 33. Le Tableau de bord© 2012 Rick Radko, 32
  34. 34. Wait, the dashboard is in French too?I want a French site, but I don‟t want a Frenchdashboard because:  I don‟t know French that well.  Some of the contributors are not fluent in French.  My web person doesn‟t know French.Fortunately, there‟s a plugin for that!© 2012 Rick Radko, 33
  35. 35. Dashboard language pluginsDashboard language plugins:  Allow you to select a language for the dashboard separate from the site.  Some have per user settings.  Some have options for the front-end tool bar.  Some have language selectors for the login screen.*Dashboard language plugins fool WordPress by overriding thelocale for the dashboard.**The language files need to be installed for each language youwant to use in the dashboard.© 2012 Rick Radko, 34
  36. 36. Dashboard language plugin examplesSome dashboard language plugins: (there aremore)  WP Native Dashboard dashboard/  Backend Localization backend-localization/© 2012 Rick Radko, 35
  37. 37. What about adding plugins and themes?An added plugin or theme shows some Englishtext:  On the front-end.  It needs to be localized.  In the dashboard.  Does it matter?© 2012 Rick Radko, 36
  38. 38. Plugins & themes for other languagesTo use plugins or themes with WordPress inanother language:  They need to be internationalized.  If they are not, look elsewhere, it typically requires a lot of code change to internationalize any sizable plugin or theme. (You also then have a maintenance nightmare)  Localization is great, but not required.  That means that there is no language file for the language you need.  If it is internationalized, you can localize it, sometimes more easily than you would think.© 2012 Rick Radko, 37
  39. 39. Checking for internationalizationCheck the plugin or theme description for:  Any mention of language support.  Any mention of translations, or translation credits.  Any mention of localizable.  Lists of languages.If you find any of these, then it is at leastinternationalized.  You still may need to create a localization for your language though.© 2012 Rick Radko, 38
  40. 40. Themes have some tags to help tooSome themes on the repositoryhave been tagged with:  translation-ready  rtl-language-supportIf a theme is tagged, then it is internationalized.© 2012 Rick Radko, 39
  41. 41. Internationalization not obvious?There are more things you can do/look for tocheck for internationalization, but you need toopen up and look at the plugin/theme files.See “Internationalization, digging deeper” in the appendix.© 2012 Rick Radko, 40
  42. 42. Creating your own translationsIf there is no language file in your language for:  WordPress or  a theme or  a pluginyou can create your own.If you use a lot of plugins it is likely you will needto localize some.  Once you have the tools, it‟s not very hard.See: “Creating your own translations” in the appendix..© 2012 Rick Radko, 41
  43. 43. Plugin example: Tweet Blender in French© 2012 Rick Radko, 42
  44. 44. Tweet Blender in FrenchThe Tweet Blender translation was created by:  Making a copy of the default translation file (.pot). (renamed of course)  Entering translations for 21 of 206 strings in the file. (All that show on the front-end of the site.)  Mostly times and duration, hour(s), day(s).  18 of the translations were 1 word each.The dashboard options are still in English.*NOTE: you can‟t change the actual tweet text.**”Original language” note is from another plugin I developed.© 2012 Rick Radko, 43
  45. 45. Creating a Canadian French localizationAs we have already noted:  There is no official Canadian French version.  There are differences from France French.  For example email„ or e-mail used in France, is courriel‟ in Quebec.To create a Canadian French version, start withthe France French files and modify as needed.© 2012 Rick Radko, 44
  46. 46. Installing WordPress language files manuallySometimes you will need to install language filesmanually:  If you want a multilingual site.  To convert an existing install to a new language.  Your language does not have a complete install file available.  You have created your own language files.*Formore on installing language see “Installing WordPresslanguage files” in the appendix.© 2012 Rick Radko, 45
  47. 47. Tricks for installing language filesTrick #1  Change the WPLANG parameter in the wp-config.php file to the locale you want.  remember until you load the file, the site will default to English.  Go to the Updates page in the dashboard and hit the “Re-load Now” button for the language.  This trick may not work if you have a Dashboard Language Plugin active.  Only works for languages on the repository.© 2012 Rick Radko, 46
  48. 48. Load German with trick #1  This trick does not load WordPress theme files.  Sample content is not changed. (Hello World)© 2012 Rick Radko, 47
  49. 49. More tricks for language filesTrick #2  Use WP Native Dashboard:  It‟s an option in the settings.  It only loads .mo files.  To get the .po files if you need them, switch the dashboard to that language, do an update as in trick #1.  This trick also: does not get theme files or the sample content, and only works for .org files.*The file types .po and .mo are defined in “Creating your owntranslations” in the appendix.© 2012 Rick Radko, 48
  50. 50. One more trick for language filesPlugin: Codestyling Localization this plugin: “You can manage and edit all gettext translation files (*.po/*.mo) directly out of the WordPress Admin Center without any need of an external editor.”© 2012 Rick Radko, 49
  51. 51. Multilingual web sitesA multilingual web site is a web site that has morethan one language on the same site, or relatedgroup of sites.A bilingual web site is a 2 language multilingualweb site.  The WordCamp Montreal site is bilingual or multilingual.© 2012 Rick Radko, 50
  52. 52. An obvious multilingual exampleWordCamp Montreal…© 2012 Rick Radko, 51
  53. 53. Unilingual web site definitionA unilingual web site is a web site that has onlylanguage shown on it.  The WordPress France site is a French only web site and is unilingual French, not multilingual.© 2012 Rick Radko, 52
  54. 54. WordPress is not multilingual “WordPress does not support a bilingual or multilingual blog out-of-the-box.”© 2012 Rick Radko, 53
  55. 55. WordPress is unilingualWhen you install a localized version of WordPress:  The site language is that language only.  You do get English as a default due to the way WordPress is constructed.  Even if you install more than one language, the site will still be unilingual in the locale set in the wp-config.php file.  We need to do more to get a multilingual site.© 2012 Rick Radko, 54
  56. 56. Multilingual WordPress approachesThe rest of the talk will be about setting upmultilingual sites with WordPress.To make a multilingual site you need:  All the skills we just learned for creating a unilingual site.  To add a few tricks to make it multilingual.© 2012 Rick Radko, 55
  57. 57. Multilingual general notes  No matter which approach you use, you will still have to deal with plugins and themes on a case by case basis.  Some plugins that are internationalized do not work well in some multilingual set-ups.  No approach will get you around entering content multiple times: once for each language.  Right now there is no one best approach, each has it benefits and issues.© 2012 Rick Radko, 56
  58. 58. Translation structureTranslation structure may dictate the approachtaken.Multilingual site content can be:  Symmetric or mirrored.  All content is in all languages  Each item is linked to the other languages.  Governments, and institutions.© 2012 Rick Radko, 57
  59. 59. Translation structure continued  Partially symmetric.  Most content in all languages.  Blogs – may be left in original language.  Reduces translation costs  Comments – may be left in submitted language.  Typically not practical to translate them.  Costs would be high.  Hard to be timely.  Un-connected.  Sites have a link to other languages, but not on an content item by item basis.© 2012 Rick Radko, 58
  60. 60. Multilingual with multiple sitesConceptually, the simplest implementation ofmultilingual is:  2 or more completely independent installs of WordPress, one for each language.© 2012 Rick Radko, 59
  61. 61. Issues with multiple sitesMultiple individual installs is not recommendedas:  The maintenance is high, need to update each site individually. (repeat everything for each site)  Hard to link matching pages between languages.  One plugin: Bilingual Linker (only for bilingual sites)  No dashboard connection:  Content management is more difficult.  Multiple logins.© 2012 Rick Radko, 60
  62. 62. Reasonable WordPress multilingual set-ups.3 main approaches  Single site  Using custom theme/tricks  Using multilingual plugins  Multisite© 2012 Rick Radko, 61
  63. 63. Single site multilingualA single site multilingual install needs to manageall the different language versions of:  the content  the menus  the output from themes, widgets and pluginsand co-ordinate them so that they provide thesame language for every requested page.© 2012 Rick Radko, 62
  64. 64. Single site using custom theme/tricksSingle site installs can made multilingual throughthe use of clever custom themes that use:  page templates or  custom metadata or  post categories  other tricksto define the language of the page and set thematching menus, theme text items andcorresponding sidebars.© 2012 Rick Radko, 63
  65. 65. Single site with tricks issuesThere may be issues with plugin/widget output:  Locales may not be set properly for each language with this technique.This technique:  Requires extensive theme coding.  Some content may be hard-coded in the theme.  Requires that content contributors mark content with tags, meta data or templates.  Does not support symmetric linking well.  Works best for small sites with static content.© 2012 Rick Radko, 64
  66. 66. Single site with pluginsThere are a quite a few plugins that managemultilingual WordPress single site installs.  qTranslate  WPML (not on the repository, it‟s not free)  Built-in translation system  A lot of assistive tools for translating themes and plugins.  xili-language  + some more© 2012 Rick Radko, 65
  67. 67. Single site with plugins issuesPlugin issues:  Lock-in is the #1 issue  Once you start using one of these plugins it is hard to change to something else.  Can be an issue at update time, plugin updates can lag WordPress, and plugins sometimes die.  qTranslate is barely being maintained right now and has had some bug issues over the last year with some WordPress updates.  Most sites built with these plugins will not run, or will only display 1 default language if the plugin is disabled or removed.© 2012 Rick Radko, 66
  68. 68. Single site with plugins issues  Can be complex to manage the install.  Hacks and workarounds are often needed for themes and plugins/widgets to use them with the multilingual plugins.  Complex plugins with their own data storage, like events managers, calendars may not work.  Widget management is an issue.  There is no built-in way of displaying different widgets on “different language” sites (as far as WordPress is concerned it‟s one site). Need a widget manager like:© 2012 Rick Radko, 67
  69. 69. Single site with plugins issues  Having differences in the theme, or different themes for each language is a challenge.  It is still really one site.  URL‟s are not always translated  Extra plugin is needed for qTranslate  Bugs & stability (not future proof)© 2012 Rick Radko, 68
  70. 70. Single site with plugins benefitsWith a single site with plugins:  Only one WordPress install to manage/update  Only one theme to manage.  It‟s easy to manage content.  Single dashboard and login.  Easy to link content between languages  Some plugins manage adding language files.  Some plugins help with creating translations of other plugins and themes.  WPML offers integration to a translation service.© 2012 Rick Radko, 69
  71. 71. Multilingual with multisiteHistorically single site with plugins has been themost popular technique, but:  Since WordPress 3.0 we have had multisite (network) in the standard version of WordPress.  Multisite allows you to have what appear to be multiple different WordPress sites running on one install of WordPress.  Different themes.  Different URL‟s (if you want)  You would not know it‟s one WordPress.© 2012 Rick Radko, 70
  72. 72. Multilingual with multisite continuedUsing multisite allows:  A “single” site approach.  But removes many of the negative issues with independent single site installs.© 2012 Rick Radko, 71
  73. 73. Installing multisiteTo enable multisite, you need to perform a shortsequence of steps, which include:  Dashboard setting changes.  Cutting and pasting some provided settings into configuration files.There are many guides to walk you through theprocess:  © 2012 Rick Radko, 72
  74. 74. Adding languages to multisiteYou can start your multisite install with any versionof WordPress.  If you use a localized version that will give you one language plus English.  The sample content is in the localized language.To add more languages you need to:  Install the language files manually.  Use the Codestyling Localization plugin.*See “Installing WordPress language files” in the appendix.© 2012 Rick Radko, 73
  75. 75. Setting multisite languages Once you have language files installed:  An option for site language will appear in the Settings -> General section.  It‟s also in the network admin site settings.© 2012 Rick Radko, 74
  76. 76. Multilingual with multisite issues  More complicated to install multisite WordPress  Not as simple as the regular 5-min install.  But is not hard either – maybe 10 minutes  Some plugins don‟t run on multisite.  Some duplication of effort to manage sites.  Plugins may need to be configured on each site.  Plugins that store their own data may have separate datasets on each site. This could be an issue for something like registration systems.© 2012 Rick Radko, 75
  77. 77. More multisite issues  Separate dashboards for each language site.  But there usually is only one login.  Not quite as easy to manage content.  No language connection between content items.  This can be resolved with Language Switcher Plugins for multisite.© 2012 Rick Radko, 76
  78. 78. Language switcher pluginsThese plugins help relate content items betweenthe sites and provide widgets for front-end linksbetween different language versions of content.Language switcher plugins:  Multisite Language Switcher  Multilingual Press  More?© 2012 Rick Radko, 77
  79. 79. Multilingual with multisite benefits  Reduced dependency on the plugins.  If you remove or disable a plugin used to manage language switching, all the sites still work, you just loose the linking between them.  Each site behaves as if it is a single site:  You don‟t need a plugin to manage the front-end site display.  Fewer plugin conflicts.  Sites run normally, no tricks.© 2012 Rick Radko, 78
  80. 80. Multilingual considerations  Splash page for language choice  Multilingual home page (allows language choice)  Browser or location sniffing – Don‟t!  Merged comments on symmetric content?  Merged is default with qTranslate,  Need plugins for other approaches.  Google (SEO) -> dont mix languages.  Best practice -> one language per page.© 2012 Rick Radko, 79
  81. 81. Multilingual considerationsDomains/url‟s (example pairs for bilingual French)  Single installs site only  © 2012 Rick Radko, 80
  82. 82. Multilingual considerations  Any install type:  or     © 2012 Rick Radko, 81
  83. 83. ContactRick Radko  email:  twitter: @r3designforgeSlides at: © 2012 Rick Radko, 82
  84. 84. Appendix© 2012 Rick Radko, 83
  85. 85. LinksWordPress in Your Language  uageInstalling WordPress in Your Language  Your_LanguageMultilingual WordPress  WordPress © 2012 Rick Radko, 84
  86. 86. LinksGlotpress   © 2012 Rick Radko, 85
  87. 87. Internationalization digging deeper© 2012 Rick Radko, 86
  88. 88. Checking the files for internationalization  Look in the plugin or theme folder for folders called:  Languages  Language  Lang  i18n  Check for .pot, .mo and .po files.  If any these files exist, then you can create a translation.© 2012 Rick Radko, 87
  89. 89. Internationalization still not obvious? Go deeperIf you are really desperate for a plugin or theme ina language and there is no indication that it isinternationalized:  You can check the code for things like:  __(<some text>, some domain)  _e(<some text>, some domain)  If they exist, you may be able to localize it.  You will need to create you own .pot file  This may require a lot of effortFor more info see:© 2012 Rick Radko, 88
  90. 90. What are __() and _e()?__() and _e() are the magic in the WordPress codethat lets localization work.Example: __(„Hello‟, „twentyeleven‟)  Means look for “Hello” in the language files for the Twenty Eleven theme, for current locale, say fr_FR. That would then return “Bonjour” if the files are loaded, and “Hello” if they are not.For more info see:© 2012 Rick Radko, 89
  91. 91. Creating your own translations© 2012 Rick Radko, 90
  92. 92. You need .pot, .mo. or .po files to start.POT (Portable Object Template) files are createdby the developer they have all text in the __() or_e() functions..PO (Portable Object) files are plain text files thatlist all the translation pairs. #: wp-admin/includes/upgrade.php:213 msgid "Hello world!“ msgstr "Bonjour tout le monde&nbsp;!“.MO (Machine Object) files are compiled versionsof the .po files.© 2012 Rick Radko, 91
  93. 93. You need .pot, .mo. or .po files to startIf you can‟t find a .pot, .mo, or .po file for theplugin or theme you want to translate:  Don’t try to translate it!  Try another theme, or plugin.WordPress .pot files, and other .mo, and .po filesthat you can use as starting points are of courseavailable.© 2012 Rick Radko, 92
  94. 94. Change existing .mo. or .po filesYou can often start with an existing .mo or .po fileand just change what you need.  If there is something close:  Canadian vs France French  If you only need to change a few items  Tweet BlenderSee: a lot of important details like naming conventions for your files.© 2012 Rick Radko, 93
  95. 95. Editing translation files2 editors I use are:  Poedit - the most commonly mentioned  available for Windows, Mac and Linux  Virtaal  Has translation help  Lets you add terms  available for Windows, Mac and Linux*For a complete list of tools see:© 2012 Rick Radko, 94
  96. 96. Poedit© 2012 Rick Radko, 95
  97. 97. Adding your language files to plugins & themesTo install new language files for plugins & themes,add them to the language folder you found whenchecking out the plugin or theme.Folders called:  Languages  Language  Lang  i18n*Use the same naming convention for your files as the theme orplugin.**Use your hosts cPanel or FTP functions.© 2012 Rick Radko, 96
  98. 98. Installing WordPress language files© 2012 Rick Radko, 97
  99. 99. Find the language filesFind the needed language files on:  anguage OR  the only version on “WordPress in YourLanguage” is an installer version, it may be easierto get them out of the .zip file than to find them on© 2012 Rick Radko, 98
  100. 100. Add the files to your WordPress installFor WordPress to find your language files, theyneed to be put in the folder at:  <your-site-root>/wp-content/languages/The official instructions:  in_Your_Language© 2012 Rick Radko, 99