Sabuj Kundu 12th Jul 2016

banner

As joomla cms is used by people from different countries with different language. Most joomla extension developer need to keep their joomla extension compatible for translation. Joomla support language files for translation string so it’s not a big deal. Again, it’s not like we always use the translation strings in xml(joomla form api xml) and php scripts but sometimes need to use them in Javascript. Adding translation in javascript in joomla is bit tricky. Here we will clear this for new developer.

We will split the tutorial in 3 easy step for better understanding.

Step1:
Write the translation string in .ini language file as we do always

MOD_EXAMPLE_CUSTOM_STRING="We love joomla"

Step2:

Declare translation string in .php script to add it in a global js object.

JText::script('MOD_EXAMPLE_CUSTOM_STRING');

Step3:

In any custom .js file injected from joomla you can now use the string as, make sure that you inject inject the js after you inject the translation string in step2

var myvalue = Joomla.JText._('MOD_EXAMPLE_CUSTOM_STRING');

If you think this is use full then share it in your network. Spread the Joomla love.

Joomla Custom Development

Joomla! Plugin, Module and Component Development We have more than 100 extensions approved in official Joomla extension directory, which makes us one of the leading Joomla extension developer in the world. We are expert in developing system plugins, module and components. [Click here to learn about our Joomla Extension Services]

WordPress Custom Development

Wordpress Bespoke Development

We are long time WordPress geek and we mean it. To convince you, our plugin author page in WordPress.org plugin directory is enough. So we are keeping it short and let’s see what type of custom development services we provide for wordpress.[Click here to learn about our WordPress Custom Services]