Your plugin may include a language content file for the language of your choice. Here's a sample code it may contain for the "articles" plugin:
$language = array( 'articles' => array( // 'articles' section 'articles' => array( // 'articles' group 'ca' => array( // items in 'ca' section will be available in the control panel and front end of the site 'article' => "Article", 'article_delete' => "Delete post", 'article_delete?' => "Are you sure you want to delete this post?", 'article_deleted' => "Post has been successfully deleted.", 'article_edit' => "Edit post", 'article_limit_reached' => "You have reached your limit of %limit posts. You may delete some of your existing posts to be able to create new ones.", 'article_new' => "New post", 'article_saved' => "Post has been successfully saved.", 'article_view' => "View post", 'no_article' => "Post does not seem to exist.", 'no_articles' => "Nobody posted anything yet, try again later.", 'no_articles_self' => "You didn't post anything yet." ), 'cp' => array( // items in 'cp' section will be available only in the control panel only 'example_item' => "Example item." ), ), 'privacy' => array( // 'privacy' group 'ca' => array( // items in 'ca' will be available everywhere 'privacy_article_view' => "Who may view this post" ), ), // in this group we include translation for the "articles" // it will be displayed on the "translate language" page, note the 'language_' prefix group 'config' => array( 'cp' => array( 'language_articles' => "Articles" ), ), ), 'system' => array( // 'system' section 'info' => array( // 'info' group 'ca' => array( 'articles_num' => "%articles posts", 'articles_num_one' => "%articles post" ), ), ), 'users' => array( 'privacy' => array( 'ca' => array( 'timeline_article_post' => "New articles" ), ), ) );
Note that the array has multiple sections (blogs, system, timeline and users). Sections are actually "plugin keywords" that allow you to specify that certain language content in your file should be used by some other particular plugin. Each section has one or more groups. What this does is allows the system to load only the language content that it requires instead of trying to load everything. This improves performance and memory usage.
Accessing language items
Language items can be access like this:
Where "keyword" is the keyword of the language item, "section" is the section in the array, and "group" is the group in the array. For example:
__('my_blogs', 'system_navigation'); // "My blogs" __('privacy_blog_view', 'blogs_privacy') // "Who may view this post"
If "section" and "group" have the same value, you don't need to write them both, for example these will produce the same result:
__('blog_view', 'blogs_blogs'); // "View post" __('blog_view', 'blogs'); // "View post"
If you noticed some of the language items include % symbol in them. What this does is allows you to replace parts of the language item with something else. For example:
__('article_limit_reach', 'articles'); // You have reached your limit of %limit posts __('article_limit_reach', 'articles', array('%limit' => 50)); // You have reached your limit of 50 posts
In additional to the $language array as in the example above, this file will also contain other arrays with language content of other resources such as $email_templates, $fields, $meta_tags, etc.