load_theme_textdomain()加载翻译后的主题字符串

目录

描述

译文

加载翻译后的主题字符串。

如果本地主题根目录下有一个.mo文件,该文件会被包括在$domain的被翻译字符串中。

.mo文件必须根据本地设置命名。

原文

Loads the theme's translated strings.

If the current locale exists as a .mo file in the theme's root directory, it will be included in the translated strings by the $domain.

The .mo files must be named based on the locale exactly, sv_SE.mo for example.

load_theme_textdomain() 描述

用法

<?php load_theme_textdomain$domain$path ?>

load_theme_textdomain() 用法

参数

$domain

(string) (必填) Unique identifier for retrieving translated strings.

默认值: None

$path

(unknown) (可选) The directory where the .mo file can be found (without the trailing slash).

默认值: false

load_theme_textdomain() 参数

返回值

(bool) 

This function return TRUE as textdomain well loaded, FALSE on failure.

load_theme_textdomain() 返回值

示例

1st example

The load_theme_textdomain() function should generally be called from within the after_setup_theme action hook.

The .mo files must use language-only filenames, like languages/de_DE.mo in your theme directory.

Unlike plugin language files, a name like my_theme-de_DE.mo will NOT work. Although plugin language files allow you to specify the text-domain in the filename, this will NOT work with themes. Language files for themes should include the language shortcut ONLY.

2nd example

you can use this example if you wish to switch theme language using a variable passed within the URL, for example to load the Tamazikht language, your URL would look like; www.example.com/?l=tz_MA, this will search for a .mo file with name tz_MA.mo in the language directory inside your theme.

load_theme_textdomain() 示例

注意

Internationalization and localization (other correct spellings are internationalisation and localisation) are means of adapting computer software to different languages.

  • l10n is an abbreviation for localization.
  • i18n 18 stands for the number of letters between the first i and last n in internationalization.

load_theme_textdomain() 注意

历史

  • 添加于 版本: 1.5.0

load_theme_textdomain() 历史

源文件

load_theme_textdomain() 函数的代码位于 wp-includes/l10n.php.

load_theme_textdomain() 源文件

相关