{"id":1007,"date":"2013-06-05T18:36:28","date_gmt":"2013-06-06T04:36:28","guid":{"rendered":"http:\/\/mymonkeydo.com\/?p=1007"},"modified":"2013-06-05T18:36:28","modified_gmt":"2013-06-06T04:36:28","slug":"theme-localization","status":"publish","type":"post","link":"https:\/\/mymonkeydo.com\/theme-localization\/","title":{"rendered":"Theme Localization"},"content":{"rendered":"

Wodpress theme localization seemed like an easy task. \u00a0And while all the info was there, I ran into several hiccups.<\/p>\n

PoEdit<\/h2>\n

This piece of open source software seems like a great tool for localization until it doesn’t work. \u00a0For me, it didn’t read the source files correctly. \u00a0If the _ or _e functions were not at the start of a line it did not pick it up. \u00a0So my results were always empty until I moved one of the functions to the start of the line.<\/p>\n

PoEdit doesn’t allow \u00a0you to edit. \u00a0Normally this is fine, but not good if the source files aren’t read correctly.<\/p>\n

 <\/p>\n

iCanLocalize PHP Text Scanner<\/h2>\n

This tool saved the day for me, but not without problems of it’s own. \u00a0The scanner apparently looks for the closing PHP tag “?>”. \u00a0In one of my files I had no closing tag so it didn’t work for me. \u00a0In another file I had it did have the closing tag, but it wasn’t at the end of the file so not all translations were picked up.<\/p>\n

In the end I just edited my PHP file to not have the closing PHP tags or if there were a lot, I just edited the po file manually. \u00a0After having that set I opened up PoEdit and created the .mo binary. \u00a0What a pain.<\/p>\n

 <\/p>\n

WordPress documentation<\/h2>\n

The docs say to use languageCode_CountryCode.mo. \u00a0This is not true. \u00a0In your theme, just use languageCode.mo.<\/p>\n

 <\/p>\n

qTranslate<\/h2>\n

On the up side, after doing a ton of searching for my problems I found out about qTranslate<\/a>. \u00a0It is a great WordPress plugin to make translating your website very easy. \u00a0It has a textbox\/editor for each language when you are editing your post so you can easily understand what’s going on. \u00a0It also provides some decent API to use in your themes.<\/p>\n

UPDATE: \u00a0qTranslate doesn’t really work “out-of-the-box” when using with WooCommerce. \u00a0so instead I used WPML.<\/p>\n

WPML<\/h2>\n

WPML is a bit different from qTranslate. \u00a0Instead of translating your content inside each post, you translate it all on one page. \u00a0 It’s pretty good in that \u00a0you can retrieve strings from plugins and themes and add localizations right inside of WordPress. \u00a0No need to handle .po files and go through the troubles i did. \u00a0 WPML lets you translate the attributes of products and all strings throughout the checkout (and everything else).<\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[7],"tags":[44,64],"yoast_head":"\nTheme Localization - My Monkey Do<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mymonkeydo.com\/theme-localization\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Theme Localization - My Monkey Do\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mymonkeydo.com\/theme-localization\/\" \/>\n<meta property=\"og:site_name\" content=\"My Monkey Do\" \/>\n<meta property=\"article:published_time\" content=\"2013-06-06T04:36:28+00:00\" \/>\n<meta name=\"author\" content=\"Webhead\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Webhead\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mymonkeydo.com\/theme-localization\/\",\"url\":\"https:\/\/mymonkeydo.com\/theme-localization\/\",\"name\":\"Theme Localization - My Monkey Do\",\"isPartOf\":{\"@id\":\"https:\/\/mymonkeydo.com\/#website\"},\"datePublished\":\"2013-06-06T04:36:28+00:00\",\"dateModified\":\"2013-06-06T04:36:28+00:00\",\"author\":{\"@id\":\"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829\"},\"breadcrumb\":{\"@id\":\"https:\/\/mymonkeydo.com\/theme-localization\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mymonkeydo.com\/theme-localization\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mymonkeydo.com\/theme-localization\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mymonkeydo.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Theme Localization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mymonkeydo.com\/#website\",\"url\":\"https:\/\/mymonkeydo.com\/\",\"name\":\"My Monkey Do\",\"description\":\"A Log of Coding Solutions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mymonkeydo.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829\",\"name\":\"Webhead\",\"url\":\"https:\/\/mymonkeydo.com\/author\/corey\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Theme Localization - My Monkey Do","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mymonkeydo.com\/theme-localization\/","og_locale":"en_US","og_type":"article","og_title":"Theme Localization - My Monkey Do","og_url":"https:\/\/mymonkeydo.com\/theme-localization\/","og_site_name":"My Monkey Do","article_published_time":"2013-06-06T04:36:28+00:00","author":"Webhead","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Webhead","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mymonkeydo.com\/theme-localization\/","url":"https:\/\/mymonkeydo.com\/theme-localization\/","name":"Theme Localization - My Monkey Do","isPartOf":{"@id":"https:\/\/mymonkeydo.com\/#website"},"datePublished":"2013-06-06T04:36:28+00:00","dateModified":"2013-06-06T04:36:28+00:00","author":{"@id":"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829"},"breadcrumb":{"@id":"https:\/\/mymonkeydo.com\/theme-localization\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mymonkeydo.com\/theme-localization\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mymonkeydo.com\/theme-localization\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mymonkeydo.com\/"},{"@type":"ListItem","position":2,"name":"Theme Localization"}]},{"@type":"WebSite","@id":"https:\/\/mymonkeydo.com\/#website","url":"https:\/\/mymonkeydo.com\/","name":"My Monkey Do","description":"A Log of Coding Solutions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mymonkeydo.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mymonkeydo.com\/#\/schema\/person\/b16fc650a8c182faaac896bab099b829","name":"Webhead","url":"https:\/\/mymonkeydo.com\/author\/corey\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts\/1007"}],"collection":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/comments?post=1007"}],"version-history":[{"count":0,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/posts\/1007\/revisions"}],"wp:attachment":[{"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/media?parent=1007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/categories?post=1007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mymonkeydo.com\/wp-json\/wp\/v2\/tags?post=1007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}