Proposal for a new WordPress Core feature to determine and retrieve the language a post has been written in.
View the Project on GitHub glueckpress/wordpress-post-language
Solutions to language related problems with content in WordPress are somewhat rare. Whereas a growing number of users publish content in other languages than default American English, WordPress Core up until today does not offer any feature to determine, nor to retrieve the language a post or page has been written in. This article aims to provide context and arguments for Trac ticket #_____ which proposes the implementation of a new Core feature: Post Language.
post: Database entry of the default post types post or page. Other post types are referred to by their names, like i.e. attachments.
Core (capitalized): The WordPress core software as available on WordPress.org.
WordPress Core does not (yet) provide any functionality or parameter for authors to determine the language of a singular post or page. In other words: one cannot simply mark a post as being written in a particular language.
So? Offering a basic opportunity to users for them to store the language of their content along with other post meta information would provide a new level of empowerment for both, users and developers.
The language of post content
According to this screenshot (which is the best data I have been able to get a hold of so far, thanks Zé!), by April 29, 2014 WordPress 3.9 has been downloaded roughly 1.36 times more often in other languages than the default US English. In other words:
More than every second Core download is in another language than English.
Total Core downloads: 6.589.287 (100%)
Default English: 2.807.978 (42.6%)
Others: 3.781.309 (57.4%)
(Data from April 29, 2014)
Core should not be agnostic of that trend.
Certainly not every site running WordPress in a different language than English will raise the need for content in more than that one language. Nonetheless, numbers above indicate that for a growing number of users world-wide language is or might become a highly substantial parameter.
On a side note: Given the fact we have fancy things like Post Formats in Core, the lack of a Post Language field seems somewhat odd. What do post formats do essentially besides giving theme authors a toy tool to gamify improve user experience in the front-end? Similarly, a Post Language field could just offer a simple value for developers to build upon–with only a minimum of functionality attached by default.
After all, WordPress is all about publishing content, and content inevitably has to do with language. We can’t honestly claim to “democratize publishing” while we continue to just ignore the relevance of linguistic aspects regarding content for WordPress users around the world.
The Post Language feature should place a label within the Publish Post meta box indicating language selection, for example: “This post is written in”.
It then should place a select box next to the label with a selection of languages previously defined through either the language packs available within the given WordPress install, or a filter.
Proposed Post Language select field
The selection of a language would return the ISO code for that language and store it in a database field. This could be a post meta field, or an extra field that would have to be added to the database table.
Proposed Post Language select field (expanded)
The value for Post Language
the_post_language()
get_the_post_language()
get_bloginfo( 'language' )
get_bloginfo( 'text-direction' )
language_attributes()
)post_class()
:
post_language()
<article <?php post_class(); ?> <?php post_language(); ?>>
// ouput:
<article class="foo bar" lang="en-US">
Finally, it probably would not make sense to have the Post Language feature enabled by default. Instead it could be enabled through
define( 'WP_POST_LANGUAGE', true )
(similar to WPLANG
),add_filter( 'post_language', $locale )
,One does not simply add features to WordPress Core, this I know. While the actual translation of content most certainly should remain plugin territory, Core should ultimately come to honor the relevance of language-related solutions for a huge part of the WordPress community.
I am convinced a Post Language selection field as described above would embody a quite elegant solution to an overdue problem: very basic, non-costly to those who don’t use it, yet most useful to those who were able to build upon it.
A side-project supported by Inpsyde.