久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

WordPress:Files For Direct Translation

來自站長百科
Xxf3325討論 | 貢獻2008年9月12日 (五) 11:35的版本 (新頁面: == Introduction == Although WordPress displays in U.S. English by default, the software has the built-in capability to be used in any language, or 'localized' (see [[WordPress:WordPress ...)
(差異) ←上一版本 | 最后版本 (差異) | 下一版本→ (差異)
跳轉(zhuǎn)至: 導航、? 搜索

Introduction

Although WordPress displays in U.S. English by default, the software has the built-in capability to be used in any language, or 'localized' (see WordPress:WordPress in Your Language for more information). The main capability for localization in WordPress uses the Gnu gettext system (see WordPress:Translating WordPress for more information). In the gettext system, text messages produced by WordPress's PHP files are run through a look-up function, which finds and uses the non-English equivalent of the default English word or phrase in a file. This works well for most of WordPress; however, there are a few components of WordPress that do not lend themselves to localization with gettext. This article explains why that is the case, and also shows how to localize those components of WordPress.

Where gettext Doesn't Work

There are several components of WordPress that cannot or should not be translated or localized with gettext:

  • The main WordPress README file -- it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions.
  • A few error messages are generated very early in the WordPress loading cycle, before gettext is loaded.
  • WordPress includes some JavaScript functionality, which runs on the users' browser (unlike PHP, which runs on the web server), and therefore does not have gettext available.

Internationalizing Non-gettext Components

In order to internationalize or localize components of WordPress that cannot use gettext, you will need to replace the English version of the files with a modified version, where the English text has been replaced by text in your language. A list of the files you will need to translate is below.

One note: if you are planning to release your localized files for use by others, be careful about WordPress versions! You will need to keep track of which version of WordPress they correspond to, or release different versions of the files for different versions of WordPress. You can find different versions of WordPress in the Release Archive, or if you want to get down to even more detail, the Trac Browser (a browser for the SVN source-code repository for WordPress).

List of Files to Translate

Core files (up to WP 2.5)

  • readme.html - it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions. The whole file needs to be translated.
  • wp-blog-header.php - only the error for non-existent wp-config.php needs to be translated.
  • wp-settings.php - some die commands could happen before the gettext engine is loaded, so they need to be translated.
  • wp-config-sample.php - see below.
  • wp-admin/install.php - only the error for non-existent wp-config.php needs to be translated.
  • wp-admin/setup-config.php - this is a script for automatic generation of wp-config.php, and as it runs independent of WordPress, there is no gettext. The whole file needs to be translated.
  • wp-admin/upgrade.php - only the warning message at the top of the file needs to be translated.
  • wp-includes/functions.php - there's a database error message at the end of the file that needs to be translated.
  • wp-includes/wp-db.php - database error messages need to be translated, because database loading happens early in WordPress loading.

Core files (WP 2.6)

  • readme.html - it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions. The whole file needs to be translated.
  • wp-config-sample.php - see below.
  • wp-admin/setup-config.php - this is a script for automatic generation of wp-config.php, and as it runs independent of WordPress, there is no gettext. The whole file needs to be translated.

wp-config-sample.php

Translate the instructions in the PHP comments (so that someone who doesn't speak English can figure out how to configure WordPress), and set the WPLANG variable to the correct locale. For example change:
define ('WPLANG', '');
to
define ('WPLANG', 'bg_BG');
if you are using the bg_BG locale

Replace 'put your unique phrase here' with a similar phrase in your language. Then, in wp-content/languages/<your-locale>.php put:

$wp_default_secret_key = '<the-translated-phrase>';

For example, here is what the Bulgarian files look like:

dist/wp-config-sample.php:

[...]
define('AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('SECURE_AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('LOGGED_IN_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
[...]

dist/wp-content/languages/bg_BG.php:

<?php
$wp_default_secret_key = 'вашата супер-ултра-уникална фраза сложете тук';
?>

TinyMCE files (up to WP 2.3 only)

Note: From WordPress 2.5 on there is no more need for direct translation of TinyMCE files, since their strings are contained within the main WordPress POT file.

TinyMCE is the HTML editor included in WordPress. It is written in JavaScript, and therefore uses a different system for localization. To localize TinyMCE, you will need to do the following:

  • wp-includes/js/tinymce/langs/ - create and add a file named ll_cc.js, where ll is the lower-case language code for your locale, and cc is the lower-case country code. For example, the bg_BG locale files should be named bg_bg.js. This file should contain the translations of strings in en.js (text for buttons and descriptions).
  • Several sub-directories of TinyMCE also have language directories, where you will need to do the same type of translation of their text:
    • wp-includes/js/tinymce/plugins/wphelp/langs/
    • wp-includes/js/tinymce/plugins/directionality/langs/
    • wp-includes/js/tinymce/plugins/spellchecker/langs/
    • wp-includes/js/tinymce/plugins/autosave/langs/
    • wp-includes/js/tinymce/plugins/wordpress/langs/
    • wp-includes/js/tinymce/plugins/paste/langs/
    • wp-includes/js/tinymce/langs/
    • wp-includes/js/tinymce/themes/advanced/langs/
    • Possibly others, if you have different TinyMCE plugins or themes -- search your TinyMCE directory structure for other langs directories.

Default theme

The Default WordPress theme is entirely in English. All of its files (contained in wp-content/theme/default) need to be translated. You may also want to provide other themes for your locale.

Besides the English-only version of the default theme, a gettext one also exists. It can be found in the theme folder of the wordpress-i18n svn repository.

Do not translate

  • license.txt - Should be kept in place for legal reasons. A translated version can be added to the archive.