Sunday, July 25, 2010

How to create an extension for Contao starting from a Language Pack

This tutorial is tailored for windows users, I’m sure that users of other operating system know how to adapt it to their needs :)

A few days ago I’ve released a command line script that aims to build a Contao extension starting from a language pack.

The project page is located at http://bitbucket.org/zedseries/contao_languagepack_builder/, the script can be downloaded from http://bitbucket.org/zedseries/contao_languagepack_builder/get/v1.0.1.stable.zip

Requirements

  • Php executable installed on your system (The script is written in php, so you must have a php cli installation to run it)
    If you do not have a php executable installed on your system, you can download a copy for windows at http://www.php.net/get/php-5.2.14-Win32.zip/from/a/mirror)
  • Some basic knowledge of the command line
  • An account on Contao.org (if you are a translator you can use your translator username)

    Getting started

    1. Create a folder into the drive C:\ and name it contao_language_extension
    2. Download the zip file containing the command line script and unzip it into the above dir
    3. Download the language pack from the Contao.org website (http://www.contao.org/download.html#translations) and put it (without unzipping) into the folder created in step 1.
    4. Create a folder (that will contain the extension built by the script) named out.

    If you have something like this:

    directory_schema

    you can go on :)

    Customize the extension

    Create a copy of C:\contao_language_extension\contao_languagepack_builder\package\package.xml.sample and rename it to package.xml.

    Edit the package.xml (will looks like this):

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE typolightpackage>
    <extension name="%languagepack_name%" date="%today%">
    <author user="__YOUR_ACCOUNT_NAME_AT_CONTAO" name="__YOUR_NAME__" />
    <copyright>__YOUR_COPYRIGHT_NOTICE__</copyright>
    <license>LGPL</license>
    <classification type="free" category="other" />
    <release version="%version_number%" build="0" date="%today%" />
    <language code="en">
    <translator user="__YOUR_ACCOUNT_NAME_AT_CONTAO" name="__YOUR_NAME__" />
    <searchtags>languagepack,core translation</searchtags>
    <title>%langname% Language Pack</title>
    <teaser>__ENTER_A_TEASER__</teaser>

    <description>
    __ENTER_A_DESCRIPTION__
    </description>
    <releasenotes>
    %release_notes%
    </releasenotes>
    <manual link="__YOUR_WEBSITE__" />
    </language>
    </extension>



    and provide the missing information, below you will find the package.xml used by the Italian Contao Community:




    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE typolightpackage>
    <extension name="%languagepack_name%" date="%today%">
    <author user="contaocms.it" name="Italian Contao Community" />
    <copyright>(c) Italian Contao Community</copyright>
    <license>LGPL</license>
    <classification type="free" category="translation" />
    <release version="%version_number%" build="0" date="%today%" />
    <language code="en">
    <translator user="contaocms.it" name="Italian Contao Community" />
    <searchtags>languagepack,core translation</searchtags>
    <title>%langname% Language Pack</title>
    <teaser>The Italian translation by contaocms.it community
    </teaser>
    <description>The Italian translation of core modules
    </description>
    <releasenotes>
    %release_notes%
    </releasenotes>
    <manual link="http://www.contaocms.it" />
    </language>
    </extension>



    The script will take care of:






    • Package name


    • Version


    • Release notes












    Please do not modify the values between % symbol (e.g. %version_number%)




    Create the extension on the Contao repository






    Please note that this is a one-time operation, you need to accomplish it only the first time you create the extension





    Go to the extension list page on Contao.org and click on “Manage extensions” (be sure to login first)




    image




    then click on the “Add extension” button




    image




    Fill in the fields as illustrated below and click on the “Add extension” button




    image




    The extension is now listed in your extension list.




    Build the extension




    Open the command line window. In Windows 2000 and XP, select Start, Programs (All Programs in XP), Accessories, Command Prompt. Alternatively, you can open the window by choosing Start, Run, typing command (in Windows 98 and Me) or cmd (in 2000 and XP), and pressing <Enter>.




    Type the following command into the window




    c:\>c:\php5\php.exe c:\contao_language_extension\contao_languagepack_builder\build_languagepack.php c:\contao_language_extension\TYPOlight-Italian-v24.zip c:\contao_language_extension\out



    You will be prompted with a summary screen:




    Contao Language Pack builder by zedseries.com
    ====================
    A Contao extension will be created with the following settings:

    sourceFile : c:\contao_language_extension\TYPOlight-Italian-v24.zip
    destinationDir : c:\contao_language_extension\out
    languageName : italian
    versionNo : 010000249

    Do you wish to continue (y/n)?




    Just type “y” to go on.




    A new fill will be created into the out  folder




    C:\CONTAO_LANGUAGE_EXTENSION
    ¦ TYPOlight-Italian-v24
    .zip
    ¦
    +---contao_languagepack_builder
    ¦ ¦
    .hgignore
    ¦ ¦
    .hg_archival.txt
    ¦ ¦ build_languagepack
    .php
    ¦ ¦ CHANGELOG
    .txt
    ¦ ¦ README
    .txt
    ¦ ¦
    ¦
    +---lib
    ¦ ¦ cmd_class
    .php
    ¦ ¦ utils
    .php
    ¦ ¦ zip
    .class.php
    ¦ ¦
    ¦
    +---package
    ¦ package
    .xml
    ¦ package
    .xml.sample
    ¦
    +---out
    TYPOlight_italian_languagepack_010000249
    .zip






    Upload the extension to the repository




    Go to the manage extensions page on Contao.org click on the “Upload package” button, then click the “Browse” button and select the file in the out folder. Once selected click on the Upload package button.




    Publish the release




    The final step is to publish the release, at http://www.youtube.com/watch?v=L_IphZYBY_8#t=3m08s you will find a video tutorial on how to accomplish this step.




    Need help?




    Feel free to comment below if you need further assistance.

    No comments:

    Post a Comment