I'm using English, Spanish and German as three store views for my site. What is the easiest way to add translations for new words?
Even if I add new words with the translations it doesn't show in the frontend.
For this:
<?php echo Mage::helper('catalog')->__('Text here');?> Add like:
app/locale/{lang_ISO}/Mage_Catalog.csv
"Text here","Translation here" For this:
<?php echo $this->__('Text here'); ?> Or this (in theme local.xml, note the translate attribute; also see https://stackoverflow.com/a/8408058/794071):
<reference name="top.links"> <action method="addLink" translate="label title"> <label>Text here</label> <title>Text here</title> </action> </reference> Add like:
app/design/frontend/{interface}/{theme}/locale/{lang_ISO}/translate.csv
"Text here","Translation here" E.g.: in your theme folder:
/locale/fr_FR/translate.csv
"Inspiration","Your France Translation" You don't really translate words. You need to translate static blocks, pages, attributes, e-mail templates and configuration related elements from the backend. To translate system strings, there's app/design/frontend/{package}/{theme]/locale/{locale}/translate.csv
{locale} could be for example de_DE for the German language used in Germany.
Modification of translation files at app/locale/{locale}/ is NOT advised as they are part of language packages and should be regarded as core elements that may get overwritten as soon as the package is updated.
It can be done in these easy steps. Step 1: Create new store view. By admin of our store go to STORES->Settings->All stores. Create Store View. Select store and give name for example Hindi. Go to STORES->Settings->Configuration. At the top-left corner in Store View Select your store view Hindi. In General tab Locale Option Select Hindi(India) from the Dropdown.
Step 2: Set your theme to this Store view. From admin Go to CONTENT->Design->Configuration Edit your Store view and set the theme.
Step 3:Create csv file in <magento dir>/app/design/frontend/<vendorName>/<themeName>/i18n/hi_IN.csv (hi_IN for Hindi). Contents are:
"Sign In", "Your Text" "My Account","Your Text" "My Wish List", "Your Text"
Step 4:Deploy the content. in magento directory of your terminal php bin/magento setup:static-content:deploy -f en_US hi_IN Clean the cache and refresh the page. After switching to new store view your changes will be showing. This will work for magento 2.2.x
What is the easiest way to add translations for new words?
I guess the tech part is answered ... :)
To make it "easy" - or to speed up l18n - you can automatically translate CSV files.
This may be useful if you have installed or built an extension that has only en_US.csv included.
Req:
https://github.com/chriskonnertz/DeepLy
composer require chriskonnertz/deeply CSV to translateadd simple PHP script
<?php require 'vendor/autoload.php'; use ChrisKonnertz\DeepLy\DeepLy; $deepLy = new DeepLy(); $read = fopen('en_US.csv','r'); $write = fopen('de_DE.csv','w'); while (($data = fgetcsv($read, 0, ",")) !== false) { $data[1] = $deepLy->translate($data[0], 'DE', 'EN'); echo "From: " . $data[0] . "\n"; echo "To: " . $data[1] . "\n"; fputcsv($write, $data); } fclose($read); fclose($write); Not really nice, but it works ... :P
I'm not related to deeply, it just saved me a couple of hours ... sorry for advertising.