Mail: [email protected] Phone: +1(628) 800-7750
Everything you need to know about 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.
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 github.com and submit those as a pull request so that we can merge it to the core and everyone can benefit from it.
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.
To proceed, we need to generate the localization file for the system and the modules. Let's start with 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.
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.
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 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.
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.