Smart Work-around Gets You Ready For Magento 2 Translation

For Magento 2 translation, there are many ways to translate theme, extension or frontend and backend. In this tutorials, we will guide you through how to translate all things in Magento 2 effectively. In other words, quick and easy-to-follow steps to create translation dictionaries and language packages will be revealed.

Let’s get started!

1.Run the following command

php bin/magento i18n:collect-phrases -o fr_FR.csv -m /Library/WebServer/Documents/lof/magento2

Above command will create 1 file fr_FR.csv contained entire text which can be translated into folder /Library/WebServer/Documents/lof/magento2

 Edit text

“You have no items in your shopping cart.”,”Votre panier d’achat ne contient plus aucun produit.”,

2.Create the need directories

a) Create folder app/i18n
b) Create folder app/i18n/Test
c) Create folder app/i18n/Test/fr_FR

Create the need files
a) Create file app/i18n/Test/fr_FR/composer.json within content:

{
"name": "Lof/language-fr_fr",
"description": "French Language",
"version": "100.0.2",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*"
},
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}

b) Create file app/i18n/Test/fr_FR/language.xml

<?xml version="1.0"?>
<!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -->
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
   <code>fr_FR</code>
   <vendor>lof</vendor>
   <package>fr_fr</package>
</language>

c) Create file app/i18n/Test/fr_FR/registration.php

<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/\Magento\Framework\Component\ComponentRegistrar::register(
   \Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
   'lof_fr_fr',
   __DIR__
);
 

d) Copy file fr_FR.csv into folder

3. Access to Admin

Admin > Store > Configuration > General > Locale Options and change to Locacle = French(France)

4. Run the following command

php bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy fr_FR
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

5. Access to checkout Page

This is one of the most effective ways of creating Magento 2 Translation dictionaries and language packages. If you have any questions or feedback, feel free to left them in the comment section down below.

Related Tutorials & Magento 2 Extensions

Admin Admin

View Comments

  • First of all. Thank for your shared.
    Equivalent I try create a package for Vietnamese but when run
    magento setup:static-content:deploy vi_VN
    Requested languages: vi_VN
    Undefined offset: 1>

    Please give me some reason about this error and how to solved it.
    Thank very much!

Recent Posts

15+ Must-have Magento 2 Free Extensions To Supercharge Your Store In 2025 | Latest updates

Magento 2 is an incredibly flexible and powerful eCommerce platform that can be tailored to…

1 week ago

Black Friday 2024: Hot Deals Collection For Magento 2

Black Friday and Cyber Monday – BFCM 2024 are nearly around the corner, and it’s…

1 week ago

What To Consider While Using Magento 2.0 For Your Streaming App?

When it comes to e-Commerce platforms, undoubtedly Magento 2.0 grabs the spotlight. Magento might not…

1 week ago

Landofcoder BFCM 2024: Biggest Sale Of The Year – 30% OFF All Magento 2 Extensions

The holiday shopping season is here, and there’s no better time to supercharge your Magento…

2 weeks ago

Top 10 Progressive Web App Development Companies To Elevate Your Business

In today’s digital landscape, the rapid evolution of advanced web applications, particularly Progressive Web Apps…

2 weeks ago

Why Your Retail Business Needs Big Data eCommerce In 2025?

As eCommerce booms, big data eCommerce will be all about providing insight into how to…

2 weeks ago