- Moodle 1.9 Extension Development
- Jonathan Moore Michael Churchward
- 287字
- 2021-08-06 17:24:05
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:

- Dreamweaver基礎(chǔ)與實(shí)戰(zhàn)教程
- 虛擬現(xiàn)實(shí):開啟現(xiàn)實(shí)與夢(mèng)想之門
- Microsoft BizTalk Server 2010 Patterns
- 穿越Photoshop CC
- 3ds Max 2014從入門到精通
- 下一代空間計(jì)算:AR與VR創(chuàng)新理論與實(shí)踐
- Photoshop圖形圖像處理實(shí)用教程
- Google App Engine Java and GWT Application Development
- Photoshop CS6案例教程(第3版)
- 中文版Photoshop CS6從新手到高手·全彩版
- Puppet權(quán)威指南
- 新編中文版3ds Max 2016入門與提高
- 玩轉(zhuǎn)電子設(shè)計(jì):基于Altium Designer的PCB設(shè)計(jì)實(shí)例(移動(dòng)視頻版)
- Photoshop CC圖像處理案例教程(第2版)
- Learning Ext JS