Skip to content

Instantly share code, notes, and snippets.

@HirokazuNishi
Last active December 9, 2017 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HirokazuNishi/f5586b3710e25e487a8667969a47c369 to your computer and use it in GitHub Desktop.
Save HirokazuNishi/f5586b3710e25e487a8667969a47c369 to your computer and use it in GitHub Desktop.
Magento2 simple check script for CJK
<?php
$lang = ['ja_JP','ko_KR','zh_Hans_CN','zh_Hant_TW','en_US'];
foreach($lang as $_lang) {
$bundle = new \ResourceBundle($_lang, 'ICUDATA');
$icuData = iterator_to_array($bundle['calendar']['gregorian']['monthNames']['format']);
if(array_key_exists('abbreviated', $icuData))
{
echo $_lang . " is available on your env.\n";
} else {
echo $_lang . " is not available on your env.\n";
}
}
@HirokazuNishi
Copy link
Author

Magento2 uses libICU & php-intl for its internal localization process. However, php-intl & libICU are not perfectly work for all environment.
This simple check script is aims to detect your environment can host Magento2 website for CJK.

If your PHP is correct, you may find 'abbreviated' key in each result data.
From my research, these environment could not return expected result.

  • CentOS7.x + php70w
  • CentOS7.x + php70u
  • CentOS7.x + remi's php7
  • CentOS6.x + remi's php7

@HirokazuNishi
Copy link
Author

CentOS7.x + php70u can work on ko_KR and zn_CH, but ja_JP can't.

@HirokazuNishi
Copy link
Author

Amazon Linux(2016.03.3) + php70 packages is same.

@kzkick2nd
Copy link

Magento 2.1.2 + CentOS7.2 + php56u
not available = ja_JP, ko_KR

@sneh-tidbit
Copy link

Yes, I understand the issue but what should I do now to remove this error.
error: Fatal error: Uncaught TypeError: Argument 1 passed to iterator_to_array() must implement interface Traversable, null given in /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Element/Html/Calendar.php:86 Stack trace: #0 /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Element/Html/Calendar.php(86): iterator_to_array(NULL) #1 /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Element/AbstractBlock.php(659): Magento\Framework\View\Element\Html\Calendar->_toHtml() #2 /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Layout.php(542): Magento\Framework\View\Element\AbstractBlock->toHtml() #3 /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Layout.php(518): Magento\Framework\View\Layout->_renderBlock('head.calendar') #4 /home/rozander/public_html/epicdashcam.com/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('head.calendar') #5 /home/rozand in /home/rozander/public_html/epicdashcam.com/vendor/magento/framework/View/Element/Html/Calendar.php on line 86

Now, I cannot come into backend because of this issue. how would I solve this issue anyhow that can be a patch or something else but how would I solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment