Multilanguage in the shipping plugin

  • Posts: 76
  • Thank you received: 9
6 years 7 months ago #276911

Hi,

I'm developing a plugin delivery.
I want to use multilanguage in myplugin_configuration.php. The code snippet:

<td class="key">
        <label for="data[shipping][shipping_params][googleApiKey]"><?php
            echo JText::_('PLG_HIKASHOPSHIPPING_BYDISTANCE_GOOGLE_API_KEY');
            ?></label>
</td>
Created en-GB.plg_hikashopshipping_myplugin.ini and in myplugin.xml added unit:
<languages>
		<language tag="en-GB">en-GB.plg_hikashopshipping_myplugin.ini</language>
</languages>
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?

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
6 years 7 months ago #276920

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 :

<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.

  • Posts: 76
  • Thank you received: 9
6 years 7 months ago #276972

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!

Please Log in or Create an account to join the conversation.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
6 years 7 months ago #276991

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.

Please Log in or Create an account to join the conversation.

  • Posts: 76
  • Thank you received: 9
6 years 7 months ago #276994

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.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
6 years 7 months ago #277002

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

Please Log in or Create an account to join the conversation.

  • Posts: 76
  • Thank you received: 9
6 years 7 months ago #277007

Obviously the developers of the bfmanual plugin are faced with the same problem, so they are in the plugin there is a method:

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.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
6 years 7 months ago #277012

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.

The following user(s) said Thank You: IGrock

Please Log in or Create an account to join the conversation.

  • Posts: 76
  • Thank you received: 9
6 years 7 months ago #277028

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.076 seconds
Powered by Kunena Forum