#StackBounty: #magento2 #language Magento 2 set locale programmatically?

Bounty: 50

i am create one test php file in magento root directory.
i install ar_SA Language pack and try to convert one string English to Saudi Arabia here is my test code.


ini_set('display_errors', 1);
ini_set('max_execution_time', 0);
ini_set("memory_limit", "-1");
require './app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');

$localeInterface = $objectManager->create('MagentoFrameworkTranslateInterface');
echo $localeInterface->getLocale(); // it's print ar_SA

echo __('Check Value');

I have the corresponding translation in /i18n/ar_SA.csv file, it doesn’t print the translated sentence.

Get this bounty!!!