WantI want to add one more layer to complete the above 2 posts which are really good. If you want to go ahead and use the translation service from Joomla, you can do that too by doing the following :-
Step 1 AddAdd this in your php code , I add this to my default.php file at the top
JText::script('COM_YOURCOMPONENT_YOUR_MESSAGE');
JText::script('COM_YOURCOMPONENT_YOUR_MESSAGE');
In your JS file, add this code to the logic where your want to display the message
var message = Joomla.JText._('COM_YOURCOMPONENT_YOUR_MESSAGE'); Joomla.JText.load({success: "Success"}); Joomla.renderMessages({'success': [message]});
var message = Joomla.JText._('COM_YOURCOMPONENT_YOUR_MESSAGE'); Joomla.JText.load({success: "Success"}); Joomla.renderMessages({'success': [message]});
In your Language/en-GB/en-GB.com_yourcomponent.ini file, add the translation
COM_YOURCOMPONENT_YOUR_MESSAGE="your message"
COM_YOURCOMPONENT_YOUR_MESSAGE="your message"