Ariyan
Ariyan

Reputation: 15158

Moodle's get_string returns incorrect value

I' creating a moodle local plugin
I created a language file in local/myplugin/lang/en/local_usercertlist.php with some keys:
I created a language file in local/myplugin/lang/en/local_myplugin.php with some keys:

<?php
$string['pluginname']="My Plug-in";
$string['testkey']="Test Val";

in lib.php I use get_string like this:

get_string('testkey','local_myplugin')

But I get [[testkey]] instead of Test Val !

why? what is the problem?

Upvotes: 0

Views: 2775

Answers (3)

Egor
Egor

Reputation: 9

The solution is to simply purge the lang cache via admin control panel.

https://docs.moodle.org/28/en/Purge_all_cache

Upvotes: 0

Ariyan
Ariyan

Reputation: 15158

I just needed to increase plugin version & update moodle database;

Upvotes: 2

Russell England
Russell England

Reputation: 10221

local/myplugin/lang/en/local_usercertlist.php

Should be

local/usercertlist/lang/en/local_usercertlist.php

and

get_string('testkey','local_myplugin')

should be

get_string('testkey','local_usercertlist')

Upvotes: 1

Related Questions