How to get i18n Directory path of a module using Magento 2?

i18n folder in module useful for translation purpose in Magento 2 for multiple languages.

You can add a translated CSV file at the module or theme level under the i18n folder. The website has multiple languages and you want to translate the text to a specific locale of the store, you need to create a CSV file for respective language locale like en_US.csv, fr_FR.csv file.

i18n stand for Internationalization. i18n is a short form of the entire word. taken first character i and last character n from the Internationalization and 18 character is the middle of i and n.

You can retrieve the path of the i18n Directory of a module using the Magento\Framework\Module\Dir class.

Dir.php class contains the directory path for the separate folder,

Let’s look a simple example for getting i18n file path,

Call function,
echo $this->getI18nPath();

OutPut:
/var/www/html/magento234/app/code/Jesadiya/Modulename/i18n

You can also get the full path of csv file by appending CSV file name in the above module.