Not recognising language files

Not recognising language files

by Kieran Briggs -
Number of replies: 4

Hi, 

I have a resource mod that won't recognise the language file even though it is in the correct place.  It was fine in Moodle 2.2 but since I've upgraded it won't find them.  

For example.  My mod is in a folder called media.  The language file is in media/lang/en/media.php

and when I try to call a string I'm using get_string('url', 'media') but I just keep getting the error message

Help title string does not exist: [url, media]


I've added &strings=1 to the url so I can see where it is looking for it and it is where the actual file is.

Help, i'm pulling my hair out on what has changed between 2.2 and 2.3 to cause this.

Thanks

 

Kieran

Average of ratings: -
In reply to Kieran Briggs

Re: Not recognising language files

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators

A couple of wild guesses:

- lange string cache? try to empty it

- file permissions? the language file should be readable by your web server process

- php accelerator software? restart your webserver process

In reply to Kieran Briggs

Re: Not recognising language files

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Oh yes, this is a collision in component names. For historical reason, activity modules do not require the full frankenstyle prefix. So you can refer to your module as 'media'. But in Moodle 2.3, a new core subsystem with the same name was introduced (see MDL-29624) and now this core subsystem takes precedence.

In other words, in ideal world, components should be referred to via full component names like core_media and mod_media. But in Moodleverse, rules tend have exceptions (which then lead to problems like this).

Let me suggest following

  1. Use mod_media instead of media in get_string() calls, as in get_string('url', 'mod_media') - that should fix your current issue
  2. Try to rename the strings file to lang/en/mod_media.php (not sure if it works or even affect anything - I'm just wondering if it works)

I also realized there will be another issue with eventual translations of your plugin as both core_media and mod_media components would have their strings in media.php. Grrr we (Moodle) really need to do something about this soon.

Average of ratings: Useful (2)
In reply to David Mudrák

Re: Not recognising language files

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I'd be interested to see if David's suggestions here are going to work enough to get by.  Please let us know.

In the long term we will have to fix the exceptions in mod to make them consistent with all the other plugin types, see MDL-33783, but it has to be done carefully as it means ALL current 3rd-party activity modules need to be updated to use the correct frankenstyle.

In reply to Kieran Briggs

Re: Not recognising language files

by devl dev -

please try this in moodlelib.php file (location:lib/moodlelib.php).

with in this file, you can add some code in the following function : normalize_component

} else if (preg_match('/^(your part of lang file name)_/', $component))  {
    $type = 'your part of lang file name';
    $plugin = str_replace('(your part of lang file name)_', '', $component);
}