Facing problem to locate language file I created

Facing problem to locate language file I created

by Sandeep Gupta -
Number of replies: 5

I am developing a new feature, named Data Importer.

For this; I created a menu folder (data_importer), insider folder admin.

Inside data_importer folder, I created language folder(lang); and inside lang, we have en_utf8 folder.

Inside en_utf8, I created a language file, where all the names is stored in the used for the Data Importer feature.

 

The problem I am facing with it, is that, these functions get_string() or print_string() could not able to locate the string with the file name(I created).

It doesn’t work; so my question is, what should I do so that the get_string() or print_string() functions recognize the language file I created.

Average of ratings: -
In reply to Sandeep Gupta

Re: Facing problem to locate language file I created

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You cannot just put a folder of code anywhere. You have to put it in one of the recognised places.

For example, you could put the feature in local/data_importer, and so the lang strings are in local/data_importer/lang/en/data_importer.php, then you can access them as get_string('whatever', 'local_data_importer');

In reply to Tim Hunt

Re: Facing problem to locate language file I created

by Sandeep Gupta -

I have modified my code and follow your instruction by moving the whole bunch of code to local and created the language file as you said; still I couldn't able to access the language file by get_string() located at local/data_importer/lang/en/data_importer.php

 

Is still I am missing any bit?

Thanks for your help.

In reply to Sandeep Gupta

Re: Facing problem to locate language file I created

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ah, what I said will only work in Moodle 2.0. Is that the problem?

In reply to Tim Hunt

Re: Facing problem to locate language file I created

by Sandeep Gupta -

Sorry but currenty, I m using, Moodle 1.9.10

Do I have to mention the language file name somewhere else to use the function get_string()?

Thanks for looking into this matter.

In reply to Sandeep Gupta

Re: Facing problem to locate language file I created

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

I would recommend to implement your plugin as admin report called dataimporter (note there is no underscore). Put it into /admin/report/dataimporter folder (see other /admin/report for examples).

The English strings for your report should then go into the file /lang/en_utf8/report_dataimporter.php (again see other report_* files as a template).

Your get_string() calls will then look like

get_string('helloworld', 'report_dataimporter');

Have fun!

Average of ratings: Useful (1)