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

Islandora 2395: Hook for Overwriting Human Readable Language Names #98

Open
wants to merge 5 commits into
base: 7.x
Choose a base branch
from

Conversation

megwill4268
Copy link

ISLANDORA-2395: https://jira.duraspace.org/browse/ISLANDORA-2395

A hook that allows the human readable language names to be overwritten so users can define their own needed languages.

Related to closed pull request #93

I do have a CLA on file:
https://github.com/Islandora/islandora/wiki/Contributor-License-Agreements

@megwill4268 megwill4268 closed this Mar 1, 2019
@whikloj
Copy link
Member

whikloj commented Mar 7, 2019

Hi @megwill4268, just wondering if there was a reason you closed this work? It seemed to be good work towards the associated ticket. Let me know.

@megwill4268
Copy link
Author

Hi @whikloj it was failing the travis ci tests so I retracted it. I'll re-open it. I haven't gotten a chance to see what in syntax wasn't passing the checks.

@megwill4268 megwill4268 reopened this Mar 8, 2019
@bondjimbond
Copy link

@megwill4268 Looks like this may be a problem with the .travis.yml file and not your code. Are other pulls to islandora_ocr failing too? I know islandora_scholar is having this problem.

@whikloj
Copy link
Member

whikloj commented Mar 11, 2019

@megwill4268 looks like you need a space as described here, normally this is because you have

function someFunction(){

and it wants

function someFunction() {

@bondjimbond due to Islandora/islandora#714 a lot of modules need a lot of love to fix outstanding issues now that we have updated code sniffer. That could be the issue with islandora_scholar as well.

@megwill4268
Copy link
Author

@whikloj looks like that fixed it :)

Copy link
Member

@whikloj whikloj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works out of the box, but I ran into some issues when implementing the hook.

'ita' => t('Italian'),
);
$language_names = module_invoke_all('get_ocr_tesseract_languages');
if (is_null($language_names)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module_invoke_all is going to return an array and in the default case an empty one. So you should probably do something like

if (count($language_names) == 0) {

* This hooks allows modules to define their own list of human readable names for the given tesseract abbreviation
*
*/
function hook_get_ocr_tesseract_languages() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hook name should have the module name in it, so I would change this to hook_islandora_ocr_get_ocr_tesseract_languages(). It is a mouthful, but I think it is required.

'jpn' => t('Japanese'),
'ita' => t('Italian'),
);
$language_names = module_invoke_all('get_ocr_tesseract_languages');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comment I left in the api.php document, you'll also need to change the name of the hook here.

@whikloj
Copy link
Member

whikloj commented Mar 14, 2019

I'll also note that the module_invoke_all returns an array with multiple strings for each language code.
For example:

if I implement this hook in modules example1 and example2. Where example1 always returns the word "example1" and example2 always returns "example2".

The value of $language_names here is

array
   'eng' => array(
      'example1',
      'example2',
   ),
   'fra' => array(
      'example1',
      'example2',
   ),
);

So we might need to pull only the first returned value (First hook wins) or loop through implementers and overwrite existing values (Last hook wins).

@whikloj
Copy link
Member

whikloj commented Jun 28, 2019

@megwill4268 are you able to move forward with this?

@DonRichards
Copy link
Member

@megwill4268 Are you able to make those requested changes?

@megwill4268
Copy link
Author

megwill4268 commented Jul 12, 2019 via email

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

Successfully merging this pull request may close these issues.

4 participants