官术网_书友最值得收藏!

Adding a language file

Like other plugins in Moodle, blocks can have their own language files to manage their display strings. They are contained within a special lang directory within the block's file structure. Moodle uses a hierarchical structure for its language folders. This is designed to allow for parent and child language folders and packs. Language packs are a collection of all of the core language strings needed to support a language. Moodle has an integrated language pack installer, which is used to add language packages for core Moodle. A good example of a parent language folder is en_utf8. The name en_utf8 indicates this is the language folder for English with Unicode encoding. A child language for English is the US dialect. This is designated with the folder name en_us_utf8. Moodle allows the child language to inherit strings defined in the parent language. This lets us rapidly develop language support for dialects by minimizing the work to defining only the strings that are different for the sub-dialect. Any strings not defined in the child language will simply be pulled from the parent.

The official documentation for language packs can be found at:

http://docs.moodle.org/en/Language_packs

Let's create a folder called lang within the helloworld folder. Next, we create another folder inside this called en_utf8. Each language will have its own folder within lang. Inside this folder, create a file with the same name as the block's primary PHP file. In our case, we will call this block_helloworld.php. Moodle stores all of its localization strings within a hash array called $string. We define our first value for the $string hash as follows:

<?PHP
$string['helloworld'] = 'Hello World';
?>

Our block and block management page (shown in the following screenshot) should now look a lot better:

Adding a language file
主站蜘蛛池模板: 始兴县| 临沭县| 富裕县| 乐清市| 云霄县| 清远市| 新绛县| 湟中县| 乌拉特前旗| 庐江县| 龙川县| 克拉玛依市| 永州市| 郯城县| 广宁县| 资源县| 绵竹市| 新化县| 富锦市| 剑川县| 色达县| 德安县| 辽源市| 大方县| 慈利县| 保定市| 建水县| 塔河县| 庆元县| 黔江区| 乌鲁木齐市| 大冶市| 阿合奇县| 大荔县| 大竹县| 张北县| 徐汇区| 榆树市| 云和县| 老河口市| 永安市|