Showing posts with label plugin. Show all posts
Showing posts with label plugin. Show all posts

Saturday 8 June 2019

How to add Language of custom plugin in Admin dashboard in wordpress



Add text for language like this "<?php echo __('General options', 'roomle'); ?>"

Step 1 : Create plugin like "roomle"
Step 2 : Set domain path into plugin file like following screenshot

Step 3 : Create "roomle.pot" inside /wp-content/plugins/roomle/languages/
Step 4 : Add like following text inside "roomle.pot" file (FYI : Don't add any translation language just add as (msgstr = ""))
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 12:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: functions.php:29
#, php-format
msgid "Roomle"
msgstr ""
#: functions.php:47
#, php-format
msgid "Select"
msgstr ""
#: functions.php:56
msgid "Roomle product type"
msgstr ""
Step 5 : Download the free plugin called Loco Translate from here. Or add directly from the WordPress administration via Plugins > Add New. (https://wordpress.org/plugins/loco-translate/)
Step 6 : Install and Activate Loco plugin
Step 7 : Click on Plugin inner menu of Loco after that click into your plugin from list.

Step 8 : Click on New language
Step 9 : Choose a language which you wish to translate (Here translate from English to Spanish)

Step 10 : See Source text (its from "roomle.pot" ) you need to add text of translate language.

Step 11 : After create all text to Spanish language, Check "/roomle/wp-content/languages/plugins/" directory. your 2 file is created here like "roomle-es_ES.mo" and "roomle-es_ES.po"
Step 12 : If you wish to check so you need to download wordpress in spanish language and setup wordpress and check

Also this answer for following question

  • How to Change the Admin plugin Language
  • How to add language into your plugin
  • How to add language into your custom plugin