Wednesday, March 19, 2008

Creating a language pack for DirectAdmin

If you would like to create your own language for the DirectAdmin skins, follow these instructions.

1) make a copy of the current language files to your own new language:

cd /usr/local/directadmin/data/skins/enhanced/lang
cp -R en yours
chown -R diradmin:diradmin *
chmod -R 755 *

Where yours is the name of the language you want to use.

2) go into yours and edit all files to show the text you want your language to have.

3) From the User Panel, go to "Site Summary / Statistics / Logs" and select your new language.


If you want to also change the text in the images to look contain your own language you'll first need to take all of the images with text in /usr/local/directadmin/data/skins/enhanced/images and edit them to look how you want. We won't go into detail on modifying images here.

Once you've made your own copies of the images (similar, but different names, in the same directory), you'll need to rename the image tags in the skins so that when a user accesses the images, the correct files are used. Go into the lang/yours directory, and edit "lf_images". There you will see all of the tags pointing to the old images that you don't want to use. You'll need to change the values of the image tags to something of your own.

Eg: change:

LANG_IMG_SKIN_HEADER=IMG_SKIN_HEADER

to:

LANG_IMG_SKIN_HEADER=IMG_YOURS_SKIN_HEADER

What that will do is replace the image tags a browser is to load to use the IMG_YOURS_SKIN_HEADER instead. Now we also need to link IMG_YOURS_SKIN_HEADERS to your new files. Usually, this is done by adding the IMG_YOURS_SKIN_HEADER to the files_user.conf. BUT since all updates will just end up overwriting this file, a new file will be used:

files_custom.conf

This file should not be included in any skins, and for this reason, will remain intact during skin updates. What it does is overrides all other files as it's checked first. We're not too concerned about it overriding other tags in this case because we're not using the same tag name (so that when you change languages, you'll see different images). The important aspect of it is that we can add custom tags in there without fear of losing them.

Create the files_custom.conf in your skins/enhanced/ directory and add:

IMG_YOURS_SKIN_HEADER=images/header_new.gif

where "images/header_new.gif" is the location of the image. You could actually put it in lang/yours/images/header_new.gif if you wanted, as it would keep things much cleaner. It doesn't really matter though.

Once this is done, you should be able to change languages seamlessly through the User Panel, and also see the different images for the different languages. Updates should not change / destroy anything.

Note about languages: Since we are constantly adding new features, new pages will most likely have new languages files which will not exist until you add them yourself.

No comments: