Not recognising language files

Not recognising language files

Kieran Briggs -
回帖数: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

回复Kieran Briggs

Re: Not recognising language files

koen roggemans -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 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

回复Kieran Briggs

Re: Not recognising language files

David Mudrák -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像 Plugins guardians的头像 Testers的头像 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.

回复David Mudrák

Re: Not recognising language files

Martin Dougiamas -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 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.

回复Kieran Briggs

Re: Not recognising language files

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);
}