Mail: [email protected] Phone: +1(424)231-4091

Translating NexoPOS

As NexoPOS 4.x is growing, the need to have it working on various languages grows as well. While on NexoPOS 3.x we've been using PoEdit which is a freemium software, we decided to use a different approach for NexoPOS 4.x, so that it can be translated just using a text editor. This tutorial will explain everything you need to know to translate NexoPOS 4.x into your language.

Prerequirements & Limitations

At the moment, NexoPOS 4.x doesn't have an RTL layout for the dashboard. This means that for languages like Arabic, Urdu, or similar languages, we won't be able to offer a convenient layout for those languages. We believe with time, this will be fixed. Adding a new language requires a core file modification. Proceed if you know what you're doing. We strongly suggest you to perform your modification on and submit those as a pull request so that we can merge it to the core and everyone can benefit from it.

How To Register A New Language

First of all, we'll add a language code to the file config/nexopos.php.

We need to add a new pair on the index "languages". Let's assume we want to add Italian, then here is how the part should look like.

According to the language you want to add, you should use the corresponding shortcode. Check the list of shortcodes available on Wikipedia.

How To Generate Localization Files For The System and Modules

To proceed, we need to generate the localization file for the system and the modules. Let's start with the system.

Generating Localization Files For The System

You need to run the following command on the CLI.

php artisan ns:translate --extract --lang=it

Note that here we've used --lang=it because we want to export the localization for the language Italian. If you're translating for german it will be ... --lang=de, etc.

When you press enter, NexoPOS will extract the localization and create a file it.json (because we're translating for Italian) on the resources/lang directory.

We now just need to open the file and make the translation manually. I'm suggesting you use Visual Studio Code as it offers a multi cursor editing. It allow you to format the JSON file for better editing.

Now we just have to make the translation.

That's all if you want to know how to extract and translate the core. Now let's see how to translate the modules.

How To Extract Localization For Modules

First of all, we need to know the identifier of the module we want to translate. Note that the modules are installed on the folder "modules" on your system. So we need to browse that folder and get the module identifier. Usually, all folders inside are named using the module identifier. For the case of Gastro 4.x, the folder is "NsGastro"; For the Multi-Store module, the folder is named "NsMultiSore". If you would like to translate a different module not provided by us, you should refer to the developer to get the module identifier.

So let's assume you want to translate Gastro 4.x in Italian, you'll need to run the following command.

php artisan ns:translate NsGastro --extract --lang=it

This command is similar to the previous one, but here we've added "NsGastro" which is the identifier of the module we want to translate. The CLI should output a message like this.

Now the localization will be generated on the "Resources/lang" folder of the module. In our example, the file "it.json" will be available at the following path "modules/NsGastro/Resources/Lang/it.json". Same as with the core localization file, you'll need to open that and edit with your favorite text editor.

Translation Doesn't Work

So you've done the translation, but it looks like it doesn't apply to the system. Let's see what are the possible cause for this.

  • You haven't set a language on your profile
  • The language aren't accessible from the browser.

How To Set Language From The Profile

You need to click access the profile by clicking on the user card on the header.

From there, you need to choose your language and save your settings.

The Language Aren't Accessible From The Browser

This literally means that NexoPOS 4.x cannot fetch the languages files. Usually, by checking the developer tools (F12 on the keyboard), you'll find 404 requests pointing to not existing resources (localization files).

So, we need to make sure the assets are available by running the following command :

php artisan ns:translate --symlink

We also need to do the same for the module we've created the localization file.

php artisan modules:symlink NsGastro

If the issue persists, feel free to let us know. From now you should be able to translate NexoPOS 4.x on your language.