- Posts: 76
- Thank you received: 9
Multilanguage in the shipping plugin
9 years 1 month ago #276911
by IGrock
Multilanguage in the shipping plugin was created by IGrock
Hi,
I'm developing a plugin delivery.
I want to use multilanguage in myplugin_configuration.php. The code snippet:
Created en-GB.plg_hikashopshipping_myplugin.ini and in myplugin.xml added unit:
After installing the plugin en-GB.plg_hikashopshipping_myplugin.ini appeared in /mysite/administrator/language/en-GB/en-GB.plg_hikashopshipping_myplugin.ini, but the constants are not framed on the page (screenshot).
Am I doing something not right or a multilanguage in hikashopshipping not supported?
I'm developing a plugin delivery.
I want to use multilanguage in myplugin_configuration.php. The code snippet:
Code:
<td class="key">
<label for="data[shipping][shipping_params][googleApiKey]"><?php
echo JText::_('PLG_HIKASHOPSHIPPING_BYDISTANCE_GOOGLE_API_KEY');
?></label>
</td>
Code:
<languages>
<language tag="en-GB">en-GB.plg_hikashopshipping_myplugin.ini</language>
</languages>
Am I doing something not right or a multilanguage in hikashopshipping not supported?
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
9 years 1 month ago #276920
by Mohamed Thelji
Replied by Mohamed Thelji on topic Multilanguage in the shipping plugin
Hello,
The multilanguage should be supported, shipping plugins are also Joomla plugins so checking that page will probably help :
docs.joomla.org/J3.x:Developing_an_MVC_C..._language_management
Modifying the "language" code of your xml file by :
Will probably do the job.
The multilanguage should be supported, shipping plugins are also Joomla plugins so checking that page will probably help :
docs.joomla.org/J3.x:Developing_an_MVC_C..._language_management
Modifying the "language" code of your xml file by :
Code:
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_hikashopshipping_myplugin.ini</language>
</languages>
Will probably do the job.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276972
by IGrock
Replied by IGrock on topic Multilanguage in the shipping plugin
It didn't help. What was to change? The former option "language" in the XML file also worked, when you install the plugin file is copied to /MySite/administrator/language/EN-GB/. But the problem is that the language constants are not read from /MySite/administrator/language/EN-GB/EN-GB.plg_hikashopshipping_myplugin.ini.
By the way, exactly the same code in plugins hikashoppayment working fine!
By the way, exactly the same code in plugins hikashoppayment working fine!
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276991
by nicolas
Replied by nicolas on topic Multilanguage in the shipping plugin
Hi,
Both types of plugins are normal Joomla plugins and you can use translation files with them.
If the translation file is not loaded, it's probably an error in the translation file breaking the parsing of the file.
Turn on the "debug language" setting of the Joomla configuration page and try again.
You'll see at the bottom of the page with the issue the list of language files and if there was an error in them and if yes, on which line.
Make sure that your translation file has no errors.
Both types of plugins are normal Joomla plugins and you can use translation files with them.
If the translation file is not loaded, it's probably an error in the translation file breaking the parsing of the file.
Turn on the "debug language" setting of the Joomla configuration page and try again.
You'll see at the bottom of the page with the issue the list of language files and if there was an error in them and if yes, on which line.
Make sure that your translation file has no errors.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276994
by IGrock
Replied by IGrock on topic Multilanguage in the shipping plugin
No errors in **Parsing errors in language file**. But in the **Language Files Loaded** my file is missing. And in the **Untranslated Strings** is my language constants. Do you have a working example of third-party multilanguage shipping plugin?
Please Log in or Create an account to join the conversation.
9 years 1 month ago #277002
by nicolas
Replied by nicolas on topic Multilanguage in the shipping plugin
We include the translations we need directly in the main language file of HikaShop for the plugins included in HikaShop.
This shipping plugin from brainforge has translation files and is free to download:
brainforge.co.uk/downloads/hikashop-deli.../3-brainforge-manual
This shipping plugin from brainforge has translation files and is free to download:
brainforge.co.uk/downloads/hikashop-deli.../3-brainforge-manual
Please Log in or Create an account to join the conversation.
9 years 1 month ago #277007
by IGrock
Replied by IGrock on topic Multilanguage in the shipping plugin
Obviously the developers of the bfmanual plugin are faced with the same problem, so they are in the plugin there is a method:
Code:
public static function trans($text) {
$language = JFactory::getLanguage();
$language->load('plg_hikashopshipping_bfmanual', JPATH_ADMINISTRATOR, 'en-GB', true);
return jText::_($text);
}
Please Log in or Create an account to join the conversation.
9 years 1 month ago #277012
by nicolas
Replied by nicolas on topic Multilanguage in the shipping plugin
Hi,
Well, the JPlugin class (that your plugin extends through the hikashopPlugin class) has an attribute called $autoloadLanguage which will load the translation file of the plugin for you if you set it to yes by overriding the attribute in the definition of the class. Maybe you and brainforge didn't know about it and thus didn't set it ?
If you don't, then it's up to you to load the translation file like brainforge does.
Well, the JPlugin class (that your plugin extends through the hikashopPlugin class) has an attribute called $autoloadLanguage which will load the translation file of the plugin for you if you set it to yes by overriding the attribute in the definition of the class. Maybe you and brainforge didn't know about it and thus didn't set it ?
If you don't, then it's up to you to load the translation file like brainforge does.
The following user(s) said Thank You: IGrock
Please Log in or Create an account to join the conversation.
9 years 1 month ago #277028
by IGrock
Replied by IGrock on topic Multilanguage in the shipping plugin
Oh, really I didn't have $autoloadLanguage = true. Thank You, Nicolas.
Please Log in or Create an account to join the conversation.
Time to create page: 0.303 seconds