How to make the custom language pack in OpenCart 4?

In this Opencart tutorial, we will show you easy localization, and how to make the language pack in OpenCart 4. We will use “Nepalese” or “Nepali” as a new language as there is no language pack for Nepali. Once we created the language pack then we will add and activate in the OpenCart.

Time needed: 1 hour

Localization or globalization is done by making the Opencart language pack. Here are the steps to make the language pack:

  1. Create a language folder in admin/ folder

    Go to admin/language then copy en-gb/ folder and paste it and change the folder name to your language name.
    In our example, we name it “ne”.

  2. Change the flag and main language name file

    Find the flag for your language, preferable transparent png with 16*16 size. Go to admin/language/ne and then place there with the same name as code. In Nepali, it is “ne” so we make it ne.png
    Change the filename admin/language/ne/en-gb.php to admin/language/ne/ne.php

  3. Change code name to your language

    Find your language code, for Nepali, it is “ne”, now open admin/language/ne/ne.php, and change Locale code. Like:

    $_[‘code’] = ‘ne’;

    You can find the lists of ISO 639-1 Language Codes at W3Schools.

    Change others as per your language like direction, date format short, date format long, time format, decimal point, thousand points.

  4. Now start adding your language text

    Open each and every ***.php and change English text to your language text except the variable in $_[‘DONTCHANGE’]. For example, if you open admin/language/ne/ne.php then you need to change the

    $_[‘text_yes’] = ‘Yes’;
    to
    $_[‘text_yes’] = ‘हुन्छ’;

    Just change values after the equal sign. Do the same for all of the others then your admin language is ready to install.

    Opencart language pack

  5. Similarly, we need to do the same thing in the catalog/ folder, so the first step, create a language folder in the catalog/language folder

    Go to catalog/language then copy the en-gb and paste it and change the name to your language.
    In our example, we name it “ne”.

  6. Change the filename to language name and flag name to language name in catalog/ folder

    Go to catalog/language/ne and add the flag related to the country and name it as per the language code. In our example, we named it ne.png. Previously in Opencart 2.0, they had collections of flags, but now they removed in 3.0, if you still need lists of small flags collection then you can download from download small flags.
    Then, rename the en-gb.php to ne.php

  7. Replace code name to your language in catalog/ folder also

    Open catalog/language/ne/ne.php and change $_[‘code’]= ‘en’; to

    $_[‘code’] = ‘ne‘;

    Similarly if needed change other Locale as per language needs.

  8. Start changing English text to your language text in catalog/language/ne folder

    Open each and every ***.php and change English text to your language text except the variable in $_[‘DONTCHANGE’]. For example, if you open catalog/language/ne/ne.php then you need to change the

    $_[‘text_yes’] = ‘Yes’;
    to
    $_[‘text_yes’] = ‘हुन्छ’;

    Create Opencart language pack

  9. Now make a ***.ocmod.zip

    Create upload/ folder and add the admin/ and catalog/ folder and inside the admin/ folder create language/ folder and then copy the translated folder. Here we copy the ne/ folder. Then, make zip and name ****.ocmod.zip. Your extension is ready to add.
    Language pack folder structure

How to add the language in Opencart?

  • Go to Extensions >> Installer and upload the ***.ocmod.zip
  • Go to Extensions >> Modifications and Refresh it
  • Go to System >> Localisation >> Languages
  • Then add the language, in our Nepali case it is something like below:
    How to add language in Opencart
  • Select the folder of your language at Code select box.
  • If you see “Warning: You added before the language!” then ignore for the first time and save again.
  • Your language is active.

Please don’t forget to post your questions or comments so that we can add extra topics, free modules, or Opencart tutorials that we need to develop which helps to develop quality. You can follow our Twitter account @rupaknpl and subscribe to the YouTube user Opencart tutorial. Thanks a lot.

Previous articleOCMOD free module to show product availability on categories pages and modules
Next articleUndefined property: Proxy::method in storage/modification/system/engine/action.php on line

6 COMMENTS

  1. Thanks for the tutorial. You left out one minor thing. Default language function won’t work if you do only what you outlined in the tutorial. So you’ll have to change it in DB directly. Go to PHP my admin locate language table and change the status to 1 for the language that you want to be the default. Or change the status to 2 or any number other than one for languages that you don’t want to be the default. There can be only one language with status 1.

LEAVE A REPLY

Please enter your comment!
Please enter your name here