Jtext usage Analysis of Joomla language translation class, joomlajtext_php tutorial

Source: Internet
Author: User
Tags echo command smarty template

Jtext usage Analysis of Joomla language translation class, Joomlajtext


This paper describes the Jtext usage of Joomla language translation class. Share to everyone for your reference, as follows:

Basic methods of Use:

Jtext is an object of the multi-language translation in Joomla, and the most basic way to use it is as follows:

If it is a variable, it is used directly, such as:

If you need to display it, you can use the echo command to show it, which is most common in template files, such as:

echo jtext::_ (' LANGUAGE CODE ');

Language Pack files:

Joomla can support multiple languages, each language pack of files in the form of folders exist under the Languages folder, such as:

The folder name for the English language pack is: languages/en-gb/

The folder name for the traditional Chinese language pack is: languages/zh-tw/

Each language has a basic Language pack file, which will be loaded in any program running in Joomla, such as:

The English Language pack file is: En-gb.ini

The language pack file for Traditional Chinese is: Zh-tw.ini

Each language of each component (Component) will have a language pack file, which is loaded by default when the component is run, such as:

Com_community's English language pack is: En-gb.com_community.ini

Com_community's Chinese language pack is: Zh-tw.com_community.ini

How to reference a language pack file across components:

If you want to use a language pack for another component, you must first introduce the component's language pack before you can use it. If you want to use the Com_stock language pack in com_community, you can introduce it in the following ways:

$lang =& jfactory::getlanguage (); $lang->load (' Com_stock ');//The name of the component, which is the middle part of the language pack file name: En-gb.com_stock.ini

Advanced methods of Use:

If a variable appears in the statement to be translated, the jtext::sprintf () method is required for translation, and jtext::sprintf () supports the use of variables in the language pack, up to 3 variables can be supported. The format of jtext::sprintf () is as follows:

The wording of the corresponding language pack:

Such as:

JomSocial a piece of code is written like this, need to pass in the membership link and the name of the video link three variables, the code of the program is written like this:

jtext::sprintf (' CC activities FEATURED VIDEO ', $ownerUrl, $ownerName, $VIDEOURL);

The corresponding language pack is written in this way:

The video of CC activities FEATURED Video=%2$s is listed as a fine choice.

More about Joomla related content readers can view this site topic: "Symfony Framework Introductory Tutorial", "Yii framework Introduction and common skills Summary", "PHP Excellent Development Framework Summary", "Smarty Template Primer Basic Tutorial", "thinkphp Common Methods Summary", " PHP Primer for object-oriented programming, PHP string Usage Summary, Introduction to PHP+MYSQL database operations, and PHP common database operations Tips Summary

It is hoped that this article is helpful to everyone based on Joomla program design.

http://www.bkjia.com/PHPjc/1123810.html www.bkjia.com true http://www.bkjia.com/PHPjc/1123810.html techarticle jtext usage Analysis of Joomla language translation class, Joomlajtext This paper describes the Jtext usage of Joomla language translation class. Share to everyone for your reference, as follows: Basic use method: ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.