Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Hard coded strings during installation #3

Open
michael-milette opened this issue Jun 7, 2022 · 3 comments
Open

Bug: Hard coded strings during installation #3

michael-milette opened this issue Jun 7, 2022 · 3 comments

Comments

@michael-milette
Copy link
Owner

There are hard-coded language strings that are set during the installation. These strings, found in the db/install.php file, should be replaced with strings from the language pack.

@gemguardian
Copy link

@michael-milette is there an easy way for you to explain how we can replace these strings, I might take a shot at this myself.

@michael-milette
Copy link
Owner Author

Hi @gemguardian ,

Thank you for your offer to help out with this issue.

I have not looked into why these strings are stored in the database during the installation. I suspect the original authors simply did not know how to use language strings when they first wrote the plugin.

What I think would need to be done is, for each of the hard coded strings in db/install.php:

  1. Determine if there is a good reason why the string is stored in a database table instead of Moodle language strings. If there is not, proceed with the following change
  2. Move the strings into the lang/en/block_cmanager.php.
  3. Remove the code that inserts the string into the database table from the db/install.php as it won't be needed anymore.
  4. Find all instances where the string is used in PHP code and use Moodle's get_string() function to retrieve it instead of whatever method is currently being used.
  5. Add code to the db/upgrade.php so that the strings are removed from the database table when people upgrade to the new version of the plugin.

Once this is done, a nice-to-have feature would be to identify the recipients preferred language to deliver messages in their language instead of the senders language, if they are different in a multi-language Moodle environment.

I think that should do it but, like I said, I have not yet assessed exactly what would need to be done so there could be a little more.

Once this is done, you should be able to easily customize and/or translate these strings using the Language String editor that is built into Moodle. If you contribute your changes back to me and it all works well, the changes will be included in future releases of block_cmanager. Once that is published on Moodle.org, new translations can be submitted through Moodle's AMOS translations site.

Note: I am currently working on an update of the plugin this summer which cleans up a lot of the code and will make it compatible with Moodle 4+. I would be happy to include your changes relating to these language strings. By sharing your changes and getting them integrated, you won't need to keep patching the plugin each time you upgrade it in the future.

Please let me know if you intend to work on this.

Best regards,

Michael

@gemguardian
Copy link

@michael-milette Thank you for taking me through the process. I already learned how to add strings to the lang/en/block_cmanager.php, so just did my first merge to you with this fix.

It's busy but I will see if I can work on the other strings. I have not done this before :) And of course I will shared the changes with you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants