Moodle

moodle should support local/ to have its own language files.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9, 2.0
  • Fix Version/s: 1.9.5, 2.0
  • Component/s: Language
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

You should be able to put custom language files in local/

Activity

Hide
Penny Leach added a comment -

Attached diff (contains patch from MDL-13000 in part as well as it contains the instructions for implmentation in the lib/locallib.php instructions)

Show
Penny Leach added a comment - Attached diff (contains patch from MDL-13000 in part as well as it contains the instructions for implmentation in the lib/locallib.php instructions)
Hide
Penny Leach added a comment -

After a Moodle HQ skype chat we decided to rework so local/ acted more like one special plugin than a complete plugin system.

Added notes on implementation in lib/locallib.php

Show
Penny Leach added a comment - After a Moodle HQ skype chat we decided to rework so local/ acted more like one special plugin than a complete plugin system. Added notes on implementation in lib/locallib.php
Hide
Penny Leach added a comment -

Fixed in HEAD & 19 STABLE.

Show
Penny Leach added a comment - Fixed in HEAD & 19 STABLE.
Hide
Tim Hunt added a comment -

Penny, the problem with this is that it add one extra file to search for to every single get_string call.

I am sure when I implemented this locally at the OU, I made it use $module argument like 'local_xxx' and added an extra place to places_to_search_for_lang_strings.

Is it too late to change this?

Show
Tim Hunt added a comment - Penny, the problem with this is that it add one extra file to search for to every single get_string call. I am sure when I implemented this locally at the OU, I made it use $module argument like 'local_xxx' and added an extra place to places_to_search_for_lang_strings. Is it too late to change this?
Hide
Penny Leach added a comment -

Never too late

I don't have any problems with changing it other than that we're now supporting local rather than local_xxx

Show
Penny Leach added a comment - Never too late I don't have any problems with changing it other than that we're now supporting local rather than local_xxx
Hide
Tim Hunt added a comment -

Having discussed this with Penny, I will change this so that

1) get_string('str', 'local') gets strings from local/lang/local.php
2) get_string('str', 'local_hack1') gets strings from local/lang/local_hack1.php

There is one break to backwards compatibility:

3) get_string('str', 'random') will no longer find strings from local/lang/random.php

Once I have done this, I will update http://docs.moodle.org/en/Development:Local_customisation#Local_language_strings and post a warning to GDF.

Show
Tim Hunt added a comment - Having discussed this with Penny, I will change this so that 1) get_string('str', 'local') gets strings from local/lang/local.php 2) get_string('str', 'local_hack1') gets strings from local/lang/local_hack1.php There is one break to backwards compatibility: 3) get_string('str', 'random') will no longer find strings from local/lang/random.php Once I have done this, I will update http://docs.moodle.org/en/Development:Local_customisation#Local_language_strings and post a warning to GDF.
Hide
Tim Hunt added a comment -

Oops, those paths should be like local/lang/EN_UTF8/local_hack1.php

Show
Tim Hunt added a comment - Oops, those paths should be like local/lang/EN_UTF8/local_hack1.php
Hide
Tim Hunt added a comment -

Actually, case 2) is not easy to do, and not needed, so only implementing 1), which is the only thing documented on http://docs.moodle.org/en/Development:Local_customisation#Local_language_strings anyway.

Show
Tim Hunt added a comment - Actually, case 2) is not easy to do, and not needed, so only implementing 1), which is the only thing documented on http://docs.moodle.org/en/Development:Local_customisation#Local_language_strings anyway.
Hide
Penny Leach added a comment -

damnit, now I want local_hack1

mnet code needs to call lang strings with two components.

Tim is that really hard to do? Do you have a patch somewhere that I can apply locally ?

Show
Penny Leach added a comment - damnit, now I want local_hack1 mnet code needs to call lang strings with two components. Tim is that really hard to do? Do you have a patch somewhere that I can apply locally ?
Hide
Penny Leach added a comment -

(By components, I mean it wants local_something)

Show
Penny Leach added a comment - (By components, I mean it wants local_something)
Hide
Penny Leach added a comment -

As discussed in jabber - this already works by putting files like

lang/en_utf8_local/local_hack1.php

Show
Penny Leach added a comment - As discussed in jabber - this already works by putting files like lang/en_utf8_local/local_hack1.php
Hide
Tim Hunt added a comment -

Fix now merged to 2.0 as part of the commit for MDL-18669 and friends.

Show
Tim Hunt added a comment - Fix now merged to 2.0 as part of the commit for MDL-18669 and friends.
Hide
Dan Poltawski added a comment -

Hmm, commit 823ebe16 has broken backwards compatability for me

I had the file:
local/lang/en_utf8/cleo_mis.php

and was using get_string('foo', 'cleo_mis');

From the comments above it looks like moving that file to local/lang/en_utf8_local/cleo_mis.php should work, but it does not.

In lib/locallib.php the comments say:

  • Local language support
  • ----------------------
    *
  • Moodle supports looking in the local/ directory for language files.
  • You would need to create local/lang/en_utf8/local.php
  • and then could call strings like get_string('key', 'local');
  • Make sure you don't call the language file something that moodle already has one of,
  • stick to local or $clientname)

So that needs fixing if nothing else

(probably should've tested this earlier since I was watching this issue!)

Show
Dan Poltawski added a comment - Hmm, commit 823ebe16 has broken backwards compatability for me I had the file: local/lang/en_utf8/cleo_mis.php and was using get_string('foo', 'cleo_mis'); From the comments above it looks like moving that file to local/lang/en_utf8_local/cleo_mis.php should work, but it does not. In lib/locallib.php the comments say:
  • Local language support
  • ---------------------- *
  • Moodle supports looking in the local/ directory for language files.
  • You would need to create local/lang/en_utf8/local.php
  • and then could call strings like get_string('key', 'local');
  • Make sure you don't call the language file something that moodle already has one of,
  • stick to local or $clientname)
So that needs fixing if nothing else (probably should've tested this earlier since I was watching this issue!)
Hide
Tim Hunt added a comment -

Dan, you misread the above. You should put your local lang files in

lang/en_utf8_local That is, the file should be lang/en_utf8_local/cleo_mis.php

You can use lang/en_utf8_local to both add new lang files, but also to override the existing vaules of strings, or add new strings, to existing language files.

I am updating the docs now, and re-closing this bug.

Show
Tim Hunt added a comment - Dan, you misread the above. You should put your local lang files in lang/en_utf8_local That is, the file should be lang/en_utf8_local/cleo_mis.php You can use lang/en_utf8_local to both add new lang files, but also to override the existing vaules of strings, or add new strings, to existing language files. I am updating the docs now, and re-closing this bug.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: