Daniel Lefers
Daniel Lefers

Reputation: 55

Magento 2 installing language packs (nl_NL translation)

I currently have a fresh Magento 2 installation. A basicly have a store setup that is configured for the Dutch market.

I've read the Magento 2 devdocs on installating Language Packs (http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/xlate.html), although the documentation seems clear, I still have some questions.

Magento 2 comes with a pre-installed Dutch Language pack, located in vendor/magento/language-nl_nl. But the language pack does not contain any translated phrases.

I created a *.csv file with the Magento console, wich collected all phrases from the vender/magento dir source files. I suppose this file is meant to be used for distribution to translaters.

After a complete translation there are several options, and I doubt wich one fitch best in my situation;

  1. Create a theme and store a nl_NL.csv file insise the theme`s i18n dir
  2. Use the Magento command line tool to pack my translated phrases in a Magento directory

Option 1 seems to have a drawback, because my Dutch translations are not directly related to the current theme, but for the store with the configured nl_NL locale.

Options 2 is unclear to me. The Magento command i18n:pack command breaks up my nl_NL.csv source file perfectly into vendor/module/i18n/nl_NL.csv files. But packing it in the vendor/magento/ dir seems not an option because of modularity problems.

Wich steps do I have to take to create a global Dutch translation that is not related with the displayed theme, is modular and can easily be distributed with amongst all my Magento 2 Projects?

Upvotes: 3

Views: 7863

Answers (2)

Nirav Joshi
Nirav Joshi

Reputation: 2960

For i18n You can make it like this

  • Make folder named with i18n in app folder
  • make sub folder same name as your theme in i18n folder
    • EXAMPLE app/design/theme/custom from this custom this is your theme name
  • make language pack folder(s) in i18n -> custom folder like en_us or en_gb or nl_nl
  • Now your folder structure will like this app/i18n/custom/nl_nl/

Now in this your language package folder make below files, all files will be in this folder structure app/i18n/custom/en_us/

app/i18n/custom/nl_nl/composer.json

{
    "name": "custom/nl_nl",
    "description": "English (US) language",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "require": {
        "magento/framework": "100.0.*"
    },
    "type": "magento2-language",
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

app/i18n/custom/nl_nl/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>nl_NL</code>
    <vendor>custom</vendor>
    <package>nl_nl</package>
</language>

app/i18n/custom/nl_nl/registration.php

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

After this put your nl_NL.csv in your language pack folder

  • app/i18n/custom/nl_nl/nl_NL.csv

After than run this following commands

  • php bin/magento setup:upgrade
  • php bin/magento setup:static-content:deploy
  • php bin/magento cache:clean

Hope this will helps you

Upvotes: 2

Maddy
Maddy

Reputation: 996

After completing translation, you can create a "language package" under app/i18n. Folder naming conventions are <vendorname>/<language_code>. It should contain the following files - composer.json - language.xml - registration.php

Reference: http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#config-cli-subcommands-xlate-example2

Upvotes: 2

Related Questions