Custom block plugin not showing translations

Hello all,

My hidsidebars plugin is not showing the translations.
On the Translator Plugin the locale folder is not showing up either.
I deleted all the unused translations and ran php tools/upgrade.php upgrade, but the plugin doesn’t seem to register…

Not sure if it’ll help:

version.xml:

<version>
        <application>hidesidebars</application>
        <type>plugins.blocks</type>
        <release>1.0.0.0</release>
        <date>2016-01-07</date>
        <lazy-load>1</lazy-load>
        <class>HideSidebarsBlockPlugin</class>
</version>

settings.xml

<plugin_settings>
        <setting type="bool">
                <name>enabled</name>
                <value>true</value>
        </setting>
        <setting type="int">
                <name>seq</name>
                <value>6</value>
        </setting>
        <setting type="int">
                <name>context</name>
                <value>2</value><!-- BLOCK_CONTEXT_LEFT_SIDEBAR -->
        </setting>
</plugin_settings>

index.php

require_once('hideSidebarsBlockPlugin.inc.php');

return new HideSidebarsBlockPlugin();

HideSidebarsBlockPlugin.inc.php

import('lib.pkp.classes.plugins.BlockPlugin');

class HideSidebarsBlockPlugin extends BlockPlugin {
        /**
         * Install default settings on system install.
         * @return string
         */
        function getInstallSitePluginSettingsFile() {
                return $this->getPluginPath() . '/settings.xml';
        }

        /**
         * Install default settings on journal creation.
         * @return string
         */
        function getContextSpecificPluginSettingsFile() {
                return $this->getPluginPath() . '/settings.xml';
        }

        /**
         * Get the display name of this plugin.
         * @return String
         */
        function getDisplayName() {
                return __('plugins.block.hidesidebars.displayName');
        }

        /**
         * Get a description of the plugin.
         */
        function getDescription() {
                return __('plugins.block.hidesidebars.description');
        }

}

I notice a capitalization variation in require_once('hideSidebarsBlockPlugin.inc.php'); and HideSidebarsBlockPlugin.inc.php. Is that intentional?

Sorry about that @ctgraham, it’s a typo while posting.
The file name is hideSidebarsBlockPlugin.ing.php and the class name is HideSidebarsBlockPlugin.

While posting I added, by mistake, an uppercase H in the file name…

And when you browse to User Home → Journal Manager → System Plugins → Block Plugins, you see an untranslated title of "##plugins.block.hidesidebars.displayName##"regardless of the locale selected?

Yes, @ctgraham!!
That’s exactly what happens.
All translation keys are displayed as such, instead of the value/message.
And, in the locale file list in the Translator Plugin, the locale files are not displayed, which means to me, there’s something wrong with registering the plugin.

Here’s the Translator Plugin locale file list, showing the block plugins.
You’ll see that the locale file for this plugin is not available.

plugins/auth/ldap/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/developedBy/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/keywordCloud/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/readingTools/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/role/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/information/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/subscription/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/relatedItems/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/authorBios/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/help/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/user/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/notification/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/languageToggle/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/customnavbar/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/donation/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/navigation/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/fontSize/locale/pt_BR/locale.xml	EDIT
 
plugins/blocks/customFontSize/locale/pt_BR/locale.xml	EDIT
 
plugins/citationFormats/cbe/locale/pt_BR/locale.xml	EDIT

What is your system’s default locale? Do you have a locale folder for that locale in your plugin directory? If your system’s default locale is not en_US, have you tried adding a directory and file for en_US as well?

@ctgraham,

Our system is multilingual, with Portuguese (pt_BR), English (en_US) and Spanish (es_ES), enabled, so, I’ve tried as much as I could make translations as similar as possible.
For all plugins I’ve made, I’ve created language files for all languages.
I have tried registering the plugin before and after removing all languages except those, and it doesn’t work…

  • is the file naming an issue?
  • maybe file permissions?
-rw-r--r-- 1 www-data www-data 1679 Mar 31 16:31 block.tpl
-rw-r--r-- 1 www-data www-data  222 Feb 23 16:18 hidesidebar-button.png
-rw-r--r-- 1 www-data www-data 1420 Apr  1 09:37 hideSidebarsBlockPlugin.inc.php
-rw-r--r-- 1 www-data www-data  516 Feb 23 16:18 index.php
drw-r--r-- 5 www-data www-data 4096 Mar 31 13:33 locale
-rw-r--r-- 1 www-data www-data  851 Feb 23 16:18 settings.xml
-rw-r--r-- 1 www-data www-data  657 Feb 23 16:18 version.xml

Do you have this plugin posted to GitHub or another location where someone could download it and test it out?

Here it is:

http://revista.ibict.br/hidesidebars.tar.gz

I installed this in a copy of OJS 2.4.x and I do see the translations normally.

Hello @ctgraham,

There’s an alt text on the image when displaying the block plugin.
Also, on my install, the displayName is not shown on journal setup Step 5 block positioning form fields…

The permissions on the folder:

drwxr-xr-x 3 www-data www-data 4096 Apr 4 09:28 hidesidebars

File permissions:

-rw-r--r-- 1 www-data www-data 1679 Mar 31 16:31 block.tpl
-rw-r--r-- 1 www-data www-data  222 Feb 23 16:18 hidesidebar-button.png
-rw-r--r-- 1 www-data www-data 1420 Apr  1 09:37 hideSidebarsBlockPlugin.inc.php
-rw-r--r-- 1 www-data www-data  516 Feb 23 16:18 index.php
drw-r--r-- 5 www-data www-data 4096 Mar 31 13:33 locale
-rw-r--r-- 1 www-data www-data  851 Feb 23 16:18 settings.xml
-rw-r--r-- 1 www-data www-data  657 Feb 23 16:18 version.xml

Plugin on plugin management list:

##plugins.block.hidesidebars.displayName##
##plugins.block.hidesidebars.description##
ATUALIZAR  EXCLUIR

Does this plugin appear in your database in the versions table? Filter particularly by the product and product_class_name column.

Hello @ctgraham,

major 1
minor 0 
revision 0
build	0
date_installed 2016-01-07 13:34:42
current 1
product_type plugins.blocks
product hidesidebars
product_class_name HideSidebarsBlockPlugin	
lazy_load	1
sitewide 0

Hmmm… have you tried installing it on a clean copy of OJS? I wonder if it is something to do with your particular install (or journal settings)?

It was working before I started importing data from previous journals, using the import/export tool (users and issues)…

Can you check to see which import breaks it (user or issues)?

I had issues with large file sizes, memory_limit settings and so forth.
Users have crappy data on them, but nothing that actually caused problems when importing, but may add strange characters in the database…

Hello,

I’d like to report that the plugin hidesidebars is working now.
But only with 755 permissions…
Any other combination (644 or 655), it doesn’t even show up.

The difference between 6 and 7 in the first bit is whether or not the user who owns the file or directory can “execute” it. For files, execution means running the file, for example interpreting a script. For directories, execution means stat’ing the directory, that is, reading the directory contents.

Generally, your directories should have the execute bit set, and your files should not have the execute bit set.

If you are on a single-user system where other folks shouldn’t be working with your files (like a shared host), you probably want the second permissions bit to be restrictive. If you are on a multi-user system where other folks will be also working at the file level with you, you probably want less restrictive permissions for the shared group.

You can read more about permissions in general here: https://www.linux.com/learn/understanding-linux-file-permissions