23

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.

38

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"
  • 1
    Also, the {lang_ISO} depends on the default language you set up for your store in System > Configuration > General > Localization options > Locale profile. – Julien Lachal Jun 11 '14 at 15:54
3

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.

0

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

0

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
    
  • add CSV to translate
  • add 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


Notes

  • this package uses an (undocumented?) API, that requires no AUTH key. There seems to be a threshold, but it's untested
  • for developer access, there is a paid APIv2 (5€/month)
  • supports DE, EN, ES, FR, IT, NL, PL, auto-detect

I'm not related to deeply, it just saved me a couple of hours ... sorry for advertising.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.