Post by Qphoria » Sat Nov 22, 2008 12:14 am

How Do I Install or Create a New Language Pack?

How to Install a language pack
Installation of a language pack is usually as simple as dropping the new language folder into the 'catalog/language' and 'admin/language' directories on your sites ftp. You may find that a language pack designed for an earlier version of OpenCart might be missing a few translations here and there, but they can be easily added later.

But aside from just the new language files, there are also needs to add some database-based language changes. Currently, opencart uses the current language selection as part of the database query. This is unfortunately implemented poorly because if you don't add a reference to the new language in your categories, products, etc, then they don't show up for those languages.
So for now, you need to be sure that for each language you install, that you also update all the locations that will refer to that language when selected.
- All categories need to be edited to get the name and description translations.
- All products need to be edited to get the name and description translations.

Also, if the language pack didn't already include them, you will have to add the translations to the following sections:
- Default Order Statuses
- Default Payment Modules
- Default Shipping Modules

How to Create a language pack
Using "farsi" language as my example

STEP 1: Clone the original language file structure


STEP 2: Change all the values within those files to the tranlated language
For example, english.php has:

Code: Select all

// Buttons
$_['button_continue']       = 'Continue';
$_['button_back']           = 'Back';
$_['button_add_to_cart']    = 'Add to Cart';
In the farsi.php file it would be:

Code: Select all

// Buttons
$_['button_continue']       = 'ادامه دادن, دنبال كردن ';
$_['button_back']           = 'عقبى, گذشته, بدهى پس افتاده, پشت';
$_['button_add_to_cart']    = 'افزودن, اضافه كردن, زياد كردن,';
Do that for all the language files.

STEP 3: Create a sql script to install the new language. Or manually enter the steps for admin insertion if you'd prefer not to use the sql file

SQL Method:
The sql code will need to be run via phpmyadmin, usually found in your cpanel of your webhost.
Example for farsi language:

Code: Select all

INSERT INTO `language` (`language_id`, `name`, `code`, `image`, `directory`, `filename`, `sort_order`) VALUES (NULL, 'Farsi', 'fa', 'fa.png', 'farsi', 'farsi.php', '1');
Manual Method
Add this information to your readme. This explains how to manually add the new language to the system via the admin panel
1. Goto Admin->Configuration->Localisation->Language
2. Click on Insert
3. Enter the following:
Language Name: Farsi
Code: fa
Flag Image: fa.png
Directory: farsi
Main Filename: farsi.php
Sort Order: 1

STEP 4: include a famfamfam icon flag for the matching country. Name it xx.png (match the language code) into the catalog/template/default/image folder
Example for farsi language: fa.png ... -farsi.png[/img] in the catalog\template\default\image folder

STEP 5 (OPTIONAL): There are also references in the database that need to have updated language values as well
- Default Order Statuses
- Default Payment Modules
- Default Shipping Modules
You could create the sql for all of those to have a version in the new language. Or just leave it up to the store owner to manually update them.
Last edited by Qphoria on Sun Feb 01, 2009 10:05 pm, edited 1 time in total.

Donate!|OpenCart Basics|GeoZones

User avatar


Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 1 guest