=== Plugin Name === Contributors: loushou Tags: launguage support, languages, rewrite, urls Requires at least: 3.6.1 Tested up to: 3.8 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html Enables a prepended 'language' segment of all site urls, which can be used to determine the current viewing language. == Description == This plugin allows you to prepend a language abbreviation to all your site urls. When a user visits your site via a given language url, all internal links on your site are rewritten to use that language, keeping the user viewing a specific language throughout their *entire experience*. This mehtod does not require that you end users have cookies enabled. It also does not require that your end users have javascript enabled. This strictly uses the url to determine the current site viewing language. What this plugin DOES do: * prepends a language segment to most site links (ie: http://example.com/en/12/21/2012/end-of-the-world/) * adds a query variable which your theme or other plugins may check for, to determine what to display for a given site language * rewrites all dynamically generated, internal links, to include the current viewing language What this plugin DOES NOT do: * automatically translate your content * modify links embeded in you post content * place the language segment in any other location of the url, other than the beginning **Short History** This plugin was derived from the resulting investigation of a [StackOverflow question I answered][soquestion]. My research and testing showed that WordPress does not have a built in way to allow a language segment of the url. More importantly, there is no really easy way to define custom url segments, other than endpoints, without significant workaround. As such, I may find that this plugin morphs into something bigger than just language url segments. But, for now at least, that is what it is. [soquestion]: http://stackoverflow.com/questions/20754505/wordpress-add-rewrite-tag-add-rewrite-rule-and-post-link/ == Installation == 1. Either upload the plugin via your admin interface, or unzip the plugin zip file in your /wp-content/plugins/ directory 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Begin using your new 'query_var' to determine your current viewing language **Using your 'query_var'** This plugin does not automatically do anything, other than add a url segment to all your dynamically generated internal links. It does however provide a method to determine the current viewing language of your site, based on the url rewriting it has done. To get the current site viewing language abbreviation, simpy use the built-in WordPress function `get_query_var('lang')`. This function will return the currently determined site language abbreviation, from this plugin. Once you have that information, you can decide what to do with it. Maybe you have a separate 'custom field' that has alternate content of a post, which you would like to display. Or maybe you have a translator API that you can run all your site content through. Or maybe you have some other code that does something special when your site is viewed in a given language. It is up to you. == Frequently Asked Questions == = Does this plugin affect my site links and urls? = Yes. This plugin prepends a 'language' url segment to most of your site urls. This applies to urls that point to posts, pages, custom post types, tags, categories, custom taxonomies, feeds, author pages, archive pages, comments, and search. = How do I determine the current viewing language of my site? = You can use the built-in WordPress function `get_query_var('lang')` to determine the current viewing language. This function will return the current viewing language abbreviation, as determined by this plugin, based on the current url, and the current plugin settings. = Which links does this plugin modify? = It only modifies the dynamically generated links. If you have links that you have manually added to your content, those links are **not** modified. Only links that are generated via the `get_permalink()` WordPress function are modified by this plugin. = Does this plugin translate my site and it's content? = No. = Does it modify embeded links inside my post content? = No. = Can I use this plugin to put the language url segment anywhere in the url? = No. You can only prepend the language url segment. (ie: http://example.com/en/12/21/2012/end-of-the-world/) == Screenshots == == Changelog == = 0.1 = * Converted the plugin from an answer on [StackOverflow](http://stackoverflow.com/) to a plugin * Added a setting page, so settings can easily be modified via the admin == Upgrade Notice == = 0.1 = Initial release of the working plugin.