WIKI使用導(dǎo)航
站長百科導(dǎo)航
站長專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計算
- 微博營銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺
- WIKI程序與應(yīng)用
- 美國十大主機(jī)
編輯“WordPress:Files For Direct Translation”
該編輯可以被撤銷。 請檢查下面的對比以核實(shí)您想要撤銷的內(nèi)容,然后發(fā)布下面的更改以完成撤銷。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
== Introduction == | == 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. | 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 == | == Where gettext Doesn't Work == | ||
There are several components of WordPress that cannot or should not be translated or localized with gettext: | 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. | * 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. | * 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. | * 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 == | == 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. | 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 [http://wordpress.org/download/release-archive/ Release Archive], or if you want to get down to even more detail, the [http://trac.wordpress.org/browser/ Trac Browser] (a browser for the SVN source-code repository for WordPress). | 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 [http://wordpress.org/download/release-archive/ Release Archive], or if you want to get down to even more detail, the [http://trac.wordpress.org/browser/ Trac Browser] (a browser for the SVN source-code repository for WordPress). | ||
== List of Files to Translate == ? | == List of Files to Translate == ? | ||
=== Core files (up to WP 2.5) === | === Core files (up to WP 2.5) === | ||
* <tt>readme.html</tt> - 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. | * <tt>readme.html</tt> - 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. | ||
* <tt>wp-blog-header.php</tt> - only the error for non-existent <tt>wp-config.php</tt> needs to be translated. | * <tt>wp-blog-header.php</tt> - only the error for non-existent <tt>wp-config.php</tt> needs to be translated. | ||
* <tt>wp-settings.php</tt> - some <tt>die</tt> commands could happen before the gettext engine is loaded, so they need to be translated. | * <tt>wp-settings.php</tt> - some <tt>die</tt> commands could happen before the gettext engine is loaded, so they need to be translated. | ||
* <tt>wp-config-sample.php</tt> - see below. | * <tt>wp-config-sample.php</tt> - see below. | ||
* <tt>wp-admin/install.php</tt> - only the error for non-existent <tt>wp-config.php</tt> needs to be translated. | * <tt>wp-admin/install.php</tt> - only the error for non-existent <tt>wp-config.php</tt> needs to be translated. | ||
* <tt>wp-admin/setup-config.php</tt> - 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. ? | * <tt>wp-admin/setup-config.php</tt> - 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. ? | ||
*<tt>wp-admin/upgrade.php</tt> - only the warning message at the top of the file needs to be translated. | *<tt>wp-admin/upgrade.php</tt> - only the warning message at the top of the file needs to be translated. | ||
*<tt>wp-includes/functions.php</tt> - there's a database error message at the end of the file that needs to be translated. | *<tt>wp-includes/functions.php</tt> - there's a database error message at the end of the file that needs to be translated. | ||
*<tt>wp-includes/wp-db.php</tt> - database error messages need to be translated, because database loading happens early in WordPress loading. | *<tt>wp-includes/wp-db.php</tt> - database error messages need to be translated, because database loading happens early in WordPress loading. | ||
=== Core files (WP 2.6) === | === Core files (WP 2.6) === | ||
* <tt>readme.html</tt> - 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. | * <tt>readme.html</tt> - 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. | ||
* <tt>wp-config-sample.php</tt> - see below. | * <tt>wp-config-sample.php</tt> - see below. | ||
* <tt>wp-admin/setup-config.php</tt> - 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. ? | * <tt>wp-admin/setup-config.php</tt> - 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 === | === 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:<br/><tt>define ('WPLANG', <nowiki>''</nowiki>);</tt><br/>to<br/><tt>define ('WPLANG', 'bg_BG');</tt><br/>if you are using the <tt>bg_BG</tt> locale | 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:<br/><tt>define ('WPLANG', <nowiki>''</nowiki>);</tt><br/>to<br/><tt>define ('WPLANG', 'bg_BG');</tt><br/>if you are using the <tt>bg_BG</tt> locale | ||
Replace 'put your unique phrase here' with a similar phrase in your language. Then, in wp-content/languages/<your-locale>.php put: | 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>'; | $wp_default_secret_key = '<the-translated-phrase>'; | ||
For example, here is what the Bulgarian files look like: | For example, here is what the Bulgarian files look like: | ||
dist/wp-config-sample.php: | dist/wp-config-sample.php: | ||
第154行: | 第61行: | ||
?><br /> | ?><br /> | ||
</tt> | </tt> | ||
=== TinyMCE files (up to WP 2.3 only) === | === 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.'' | ''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: | 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: | ||
* <tt>wp-includes/js/tinymce/langs/</tt> - create and add a file named? <tt>ll_cc.js</tt>, where <tt>ll</tt> is the lower-case language code for your locale, and <tt>cc</tt> is the lower-case country code. For example, the <tt>bg_BG</tt> locale files should be named <tt>bg_bg.js</tt>. This file should contain the translations of strings in <tt>en.js</tt> (text for buttons and descriptions). ? | * <tt>wp-includes/js/tinymce/langs/</tt> - create and add a file named? <tt>ll_cc.js</tt>, where <tt>ll</tt> is the lower-case language code for your locale, and <tt>cc</tt> is the lower-case country code. For example, the <tt>bg_BG</tt> locale files should be named <tt>bg_bg.js</tt>. This file should contain the translations of strings in <tt>en.js</tt> (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: | * Several sub-directories of TinyMCE also have language directories, where you will need to do the same type of translation of their text: | ||
**<tt>wp-includes/js/tinymce/plugins/wphelp/langs/</tt> | **<tt>wp-includes/js/tinymce/plugins/wphelp/langs/</tt> | ||
**<tt>wp-includes/js/tinymce/plugins/directionality/langs/</tt> | **<tt>wp-includes/js/tinymce/plugins/directionality/langs/</tt> | ||
第186行: | 第78行: | ||
**<tt>wp-includes/js/tinymce/langs/</tt> | **<tt>wp-includes/js/tinymce/langs/</tt> | ||
**<tt>wp-includes/js/tinymce/themes/advanced/langs/</tt> | **<tt>wp-includes/js/tinymce/themes/advanced/langs/</tt> | ||
**Possibly others, if you have different TinyMCE plugins or themes -- search your TinyMCE directory structure for other <tt>langs</tt> directories. | **Possibly others, if you have different TinyMCE plugins or themes -- search your TinyMCE directory structure for other <tt>langs</tt> directories. | ||
=== Default theme === | === Default theme === | ||
The Default WordPress theme is entirely in English. All of its files (contained in <tt>wp-content/theme/default</tt>) need to be translated. You may also want to provide other themes for your locale. | The Default WordPress theme is entirely in English. All of its files (contained in <tt>wp-content/theme/default</tt>) 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 [http://svn.automattic.com/wordpress-i18n/theme/ theme folder of the wordpress-i18n svn repository]. | Besides the English-only version of the default theme, a gettext one also exists. It can be found in the [http://svn.automattic.com/wordpress-i18n/theme/ theme folder of the wordpress-i18n svn repository]. | ||
=== Do not translate === | === Do not translate === | ||
*<tt>license.txt</tt> - Should be kept in place for legal reasons. A translated version can be added to the archive. | *<tt>license.txt</tt> - Should be kept in place for legal reasons. A translated version can be added to the archive. | ||