1

I try to create Arabic language package for Magento 2

I follow this tutorial

https://mage2.pro/t/topic/270

I did the following command to create language dictionary

./magento i18n:collect-phrases -o "/var/www/html/magento/app/i18n/AlMouje/ar_SA/dictionary.csv" -m "/var/www/html/magento/"

and this is app folder tree

└── i18n
    └── almouje
        └── ar_SA
            ├── composer.json
            ├── dictionary.csv
            ├── language.xml
            └── registration.php

and this is the composer.json file

{
    "name": "almouje/language-ar_sa",
    "description": "Arabic (Saudi Arabia) language",
    "version": "100.0.2",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "require": {
        "magento/framework": "100.0.*"
    },
    "type": "magento2-language",
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

and this is the language.xml file

<?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>ar_SA</code>
    <vendor>almouje</vendor>
    <package>ar_sa</package>
</language>

and this is registration.php file

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
    'almouje_ar_sa',
    __DIR__
);

and when I try to load the home page I get this error

Notice: Undefined offset: 1 in /var/www/html/magento/vendor/magento/framework/App/Language/Dictionary.php on line 183
#0 /var/www/html/magento/vendor/magento/framework/App/Language/Dictionary.php(183): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined offse...', '/var/www/html/m...', 183, Array)
#1 /var/www/html/magento/vendor/magento/framework/App/Language/Dictionary.php(100): Magento\Framework\App\Language\Dictionary->readPackCsv('almouje', 'ar_sa')
#2 /var/www/html/magento/vendor/magento/framework/Translate.php(323): Magento\Framework\App\Language\Dictionary->getDictionary('ar_SA')
#3 /var/www/html/magento/vendor/magento/framework/Translate.php(181): Magento\Framework\Translate->_loadPackTranslation()
#4 /var/www/html/magento/vendor/magento/framework/App/Area.php(240): Magento\Framework\Translate->loadData(NULL, false)
#5 /var/www/html/magento/vendor/magento/framework/App/Area.php(211): Magento\Framework\App\Area->_initTranslate()
#6 /var/www/html/magento/vendor/magento/framework/App/Area.php(138): Magento\Framework\App\Area->_loadPart('translate')
#7 /var/www/html/magento/vendor/magento/framework/View/DesignLoader.php(55): Magento\Framework\App\Area->load('translate')
#8 /var/www/html/magento/vendor/magento/framework/App/Action/Plugin/Design.php(38): Magento\Framework\View\DesignLoader->load()
#9 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#10 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#11 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'storeCheck')
#12 /var/www/html/magento/vendor/magento/module-store/App/Action/Plugin/StoreCheck.php(44): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#13 [internal function]: Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#14 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#15 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'contextPlugin')
#16 /var/www/html/magento/vendor/magento/module-store/App/Action/Plugin/Context.php(98): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#17 [internal function]: Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#18 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#19 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'customer-segmen...')
#20 /var/www/html/magento/vendor/magento/module-customer-segment/Model/App/Action/ContextPlugin.php(81): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#21 [internal function]: Magento\CustomerSegment\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#22 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#23 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'customer-app-ac...')
#24 /var/www/html/magento/vendor/magento/module-customer/Model/App/Action/ContextPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#25 [internal function]: Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#26 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#27 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'weee-app-action...')
#28 /var/www/html/magento/vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#29 [internal function]: Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#30 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#31 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Cms\\Con...', 'dispatch', Object(Magento\Cms\Controller\Index\Index\Interceptor), Array, 'tax-app-action-...')
#32 /var/www/html/magento/vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#33 [internal function]: Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Cms\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#34 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#35 /var/www/html/magento/var/generation/Magento/Cms/Controller/Index/Index/Interceptor.php(39): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#36 /var/www/html/magento/vendor/magento/framework/App/FrontController.php(55): Magento\Cms\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#37 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#38 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#39 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#40 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#41 /var/www/html/magento/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(89): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#42 [internal function]: Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#43 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#44 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#45 /var/www/html/magento/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#46 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#47 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#48 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#49 /var/www/html/magento/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#50 [internal function]: Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#51 /var/www/html/magento/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#52 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#53 /var/www/html/magento/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#54 [internal function]: Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#55 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#56 /var/www/html/magento/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#57 /var/www/html/magento/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#58 /var/www/html/magento/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#59 /var/www/html/magento/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#60 {main}

2 Answers 2

3

for some reason, your csv file seems to be not valid.

The error output relates to this line: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/App/Language/Dictionary.php#L183

Each csv row must have at least 2 columns:

"Original String","Translated String"

(Ok I bet you know that)

So you should check the csv File. You could also debug at the given Codeline and try to find out, on which line (in the csv file) this error occurs

===UPDATE===

It may also be an encoding Problem. Also, Microsoft Excel for Example almost always broke my csv Files somehow, often just by opening them. I would recommend to use Openoffice or Libreoffice Calc for editing csv files

5
  • Hi David thank you for your reply I only create the dictionary I even did not change anythings
    – Salim
    Commented Feb 14, 2016 at 7:31
  • ok, still there is an error reading the file. Maybe it's still a bug in the dictionary tool of magento Commented Feb 14, 2016 at 7:35
  • and it came like this Role Scopes,Role Scopes,module,Magento_AdminGws,,,, Custom,Custom,module,Magento_AdminGws,,,, Read Details,Read Details,module,Magento_AdminNotification,,,, Mark as Read,Mark as Read,module,Magento_AdminNotification,,,,
    – Salim
    Commented Feb 14, 2016 at 7:36
  • no double cote in dictionary file
    – Salim
    Commented Feb 14, 2016 at 7:37
  • oh, that's weird, last time I tried it, it at least double quoted any string containing a whitespace Commented Feb 14, 2016 at 7:38
0

I had the same problem. The solution was removing all empty lines that had been there for no reason. Could also be an emtpy line on the end of the file.

You can get the exact line when you debug the method readPackCsv in Dictionary.php as David mentioned above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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