Create a language package, install a language package via admin?
-
01-01-2021 - |
Question
I have a Magento 2 shop hosted using a traditional cPanel
hosting solution. Performance seems to be stable with the demo data and I'd like to install a language pack.
My problem is that I can only access a file manager, or run very simple commands by creating one-time cron jobs that execute a command ! and I have to manually delete them afterwards.
How can I install a language pack using these restrictions, since I do not believe I have composer installed ?
Solution
According to your requirements, you can create a translation module yourself manually.
app/i18n/languageName/code_ISO/code_ISO.csv
Example: for the French language it will be like this:
app/i18n/french/fr_FR/fr_FR.csv
- You put your translation words inside
fr_FR.csv
like this :
"Hello","Bonjour"
- You can specify the translation for some module like this, example here is a captcha module
"Incorrect CAPTCHA","CAPTCHA incorrect",module,Magento_Captcha
- You put your translation words inside
app/i18n/languageName/code_ISO/language.xml
<?xml version="1.0"?> <language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>code_ISO</code> <vendor>languageName</vendor> <package>code_iso</package> </language>
French language example:
app/i18n/french/fr_FR/language.xml
<?xml version="1.0"?> <language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>fr_FR</code> <vendor>french</vendor> <package>fr_fr</package> </language>
app/i18n/languageName/code_ISO/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::LANGUAGE, 'languageName_code_iso', __DIR__ );
French language example:
app/i18n/french/fr_FR/registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::LANGUAGE, 'french_fr_fr', __DIR__ );
Clean your cache, deploy the static-content like this :
- Delete the contents of
pub/static
except.htaccess
- Delete the contents of
var/cache
- Delete the contents of
var/view_preprocessed
- Run this command:
php bin/magento setup:static-content:deploy -f
- Delete the contents of