I have a situation where I need to save values in couple of languages, Arabic and English at a save form, So I have two fields with the name Product Name
and اسم المنتج
i.e Product Name in Arabic, So I need a way I can translate the value in given locale i.e. ar_SA
Note: The Product Name
is the primary textbox where as the اسم المنتج
will be secondary at the Store View for en_US
and vise versa in the case of Store View for ar_SA
so I cannot hard code the text, I need it to be dynamically changed on the basis of current locale of the Store
I tried using Translate\Adapter
class here but no luck
use Magento\Framework\Translate\Adapter as TranslateAdapter;
...
$translateAdapter = new TranslateAdapter();
return $translateAdapter->translate('Edit Product', 'ar_SA');
but no luck it returns the same Edit Product
string, I already have Edit Product in my i18n/ar_SA.csv
file
"Edit Product","تحرير المنتج"
"Save","حفظ المنتج"
"Product Name","اسم المنتج"
"Description","وصف"
"Short Description","وصف قصير"