Good but not as good as hoped
-
I was previously using a plugin that allowed me to hard-code various languages and would then return the content in the language the user was browsing. This is especially necessary in areas where perhaps content need to be hard-coded such as the footer or header of a site. This plugin however, does not offer that. In fact, when I submitted a ticket, their reply was:
Unfortunately, this functionality is not available. However, you can request paid customization if you want, and provide all the details in this ticket.
Yeah, no thanks. So, jQuery to the rescue! The following is a solution I came up with and though I’d share it in case it works for you as well (likely, there’s a better solution). In my case, the site I’m developing is offered in English and Spanish so it made offering content in these languages easy enough:
<script> var url = window.location.href; if (url.search("en_US") >= 0) { $('#foot-load').load('<?php bloginfo('template_directory');?>/ref/foot-en.php'); } if (url.search("es_ES") >= 0) { $('#foot-load').load('<?php bloginfo('template_directory');?>/ref/foot-es.php'); } </script>
You just need to create a div or span with the id of #foot-load and use jQuery to load your content based on the URL the user is on – in this case, return english content if the URL contains en_US or content in Spanish if the URL contains es_ES. Thus the footer is going to returns a block of content in the users language with ease.
- The topic ‘Good but not as good as hoped’ is closed to new replies.