Joomla! (DAY 7) - Joomsport (DAY 5): Localization - Adding Traditional Chinese
来源:互联网 发布:下载解压软件 编辑:程序博客网 时间:2024/05/16 04:45
Back End:
DropDown Main Menu
The first thing need to take care is the main menu. In the drop down vertical menu, each item accords to one component installed, and each component has one item linking with it in the menu:
We've already explained that the data for this drop down menu is stored in data table '#__components' in MySQL. So if you want to change the text label, just update the corresponding record directly:
We would not waste time here.
Horizental Sub Menu:
That menu is generated by the code in 'admin.joomsport.php':
// Load the submenu.addSubmenu(JRequest::getCmd('task', 'joomsport'));function addSubmenu($vName){JSubMenuHelper::addEntry(JText::_('BLBE_TOURNAMENT'),'index.php?option=com_joomsport&task=tourn_list',$vName == 'tourn_list' || $vName == 'tour_edit' || $vName == '');JSubMenuHelper::addEntry(JText::_('BLBE_SEASON'),'index.php?option=com_joomsport&task=season_list',$vName == 'season_list' || $vName == 'season_edit');........
The text 'BLBE_TOURNAMENT' is just a key in some kind of 'language file', which stores key-value pair, and the value of that key will be evaluated in the expression and shown in HTML finally. So, now search for words ‘BLBE_TOURNAMENT’ through out the whole project:
The four highlighten files have the same content, after trying one by one, the file under 'administrator/language/en-GB/' is the right one. Change its content:
BLBE_TT_LASTNAME="Enter Last Name"BLBE_NICKNAME="Nickname"BLBE_TT_NICKNAME="Enter Nickname"BLBE_TOURNAMENT="賽事"BLBE_TOURNAMENTNAME="Tournament name"BLBE_SELTOURNAMENT="Select Tournament"BLBE_TT_SELTOURNAMENT="Select Tournament to assign the Season"BLBE_SEASON="Season"BLBE_SEASONNAME="Season name"
Then go the the administration page again:
It's done. Under directory 'administrator/components/com_joomsport/Language', there is one folder named 'BE', it should stand for 'Back End', and the 'FE' should stand for 'Front End'.
Front End
As we know, Joomla! let user has the capability to specify languages for front end and back end separately. And the language for front end is generally designed for end user level. Joomsport takes this issue into account, and it has a panel for that at back end.
But so far we have no idea about where does the language file reside. Change some words in the new created language file and search the words through the project.
But Eclipse return 0 result. Have to change the way of thinking. Take a look at front end firstly:
And, this view is 'ltable' with leyout 'default'. We should go to and open file '/components/com_joomsport/views/ltable/tmpl/default.php'.
<th width="20" class="sort asc" axis="int" id="tblrank_id"><?php echo $this->bl_lang['BL_TBL_RANK'];?></th>
And in '/components/com_joomsport/views/ltable/view.html.php':
class bleagueViewltable extends JView{function display($tpl = null){......require_once(JPATH_ROOT.DS.'components'.DS.'com_joomsport'.DS.'bl_lang.php');$this->assignRef('bl_lang', $bl_lang);......
The variable '$bl_lang' should come from 'bl_lang_php'. Open 'bl_lang_php':
<?phpdefined( '_JEXEC' ) or die( 'Restricted access' );$db=& JFactory::getDBO();require_once ( JPATH_ROOT.'/media/bearleague/languages/default.php' );$query = "SELECT lang_file FROM #__bl_languages WHERE is_default = 1";$db->setQuery($query);$lang_file = $db->loadResult();if ($lang_file){if (preg_match("/[0-9a-z]/", $lang_file)){//dumpMessage('reach here in preg');//$filelink = JPATH_ROOT.'/media/bearleague/languages/'.$lang_file.'.php';//dump($filelink, 'filelink');//$ex = file_exists($filelink);//dump($ex, 'file exist?');require_once ( JPATH_ROOT.'/media/bearleague/languages/'.$lang_file.'.php' );}}?>
It is a little wierd that put the language file under 'media/../'. This script load the default language file, and then get the language file currently in use, and then load it. The '#__bl_languages' table is:
And put some 'dump' statement to trace the intrim variables, according to the output, that the file 'Traditional Chinese.php' does exist! But why can't find it.
In fact the reason is that Eclipse will not actively, automatically refresh the project, even you close your Eclipse, you need to refresh by yourself mannually.
Localising The Whole Site
At this point, we have localised the joomsport component, but not Joomla! stie yet. It is pretty simple to add language (other than English of course), go to the official site for language package distribution, and download language pack file:
http://joomlacode.org/gf/project/jtranslation/frs/?action=FrsReleaseView&release_id=324
REFS:
http://kb.siteground.com/article/How_to_install_a_new_language_in_Joomla_15.html
http://help.joomla.org/content/view/1651/243/
- Joomla! (DAY 7) - Joomsport (DAY 5): Localization - Adding Traditional Chinese
- Joomla! (DAY 8) - Joomsport (DAY 6):
- Joomla! (DAY 9) - Joomsport (DAY 7): Create a Real View 'Home VS Away'
- Insight Joomla! (DAY 5) - Examing Joomsport (DAY 3): My First View
- Joomla! (DAY 10) - Joomsport (DAY 8): Create my own JElement
- Insight Joomla! (DAY 4) - Examing Joomsport (DAY 2) - they are the same DAY!
- Joomla! (DAY 6) - Joomsport (DAY 4): Tackling with View's Parameters - JElement
- day
- day\\\
- Select the Traditional Ceremony Attire around the Massive Day
- Chinese Valentine's Day(七巧节)
- Day 7
- day 7
- DAY 5
- Day 5
- day 5
- Day-5
- DAY 5
- uva 11503 并查集
- Smooth Image Flicking in Qt Quick
- R.layout.main cannot be resolved解决办法
- CMALLET开始,ALPHABET(遵循google c++ style)
- 工作积累(把一个数组放到combox的组件中)
- Joomla! (DAY 7) - Joomsport (DAY 5): Localization - Adding Traditional Chinese
- ADMOB的打包问题
- Android 网络连接问题
- oracle 跟踪文件和转储命令详解
- linux 多线程编程的信号问题
- SDL使用触屏模拟鼠标点击事件
- Java中string的特性
- 每日一句(想起来的时候~哈)
- 第九章:用内核对象进行线程同步(二) .