2024-04-28, 03:32 AM
(This post was last modified: 2024-04-28, 03:50 AM by baoziba. Edited 1 time in total.)
Hi I have a plugin with all the texts hard coded in English, and I'd like to support multiple languages, so I did the following to try to make it easier to translate to another language:
1) In the /inc folder, I added a "languages" folder and then an "english" folder.
2) I added a file in the "english" folder, called "myplugin.lang.php" with something like $l['myplugin_title'] = "This is an English title";
3) At the beginning of the plugin file myplugin.php in /inc/plugins, I did the following:
global $lang;
$lang->load("myplugin");
4) And then I tried to access the string value like {$lang->myplugin_title} in the php code of myplugin.php
But, it doesn't work: on the page, it shows "{$lang->myplugin_title}" instead of "This is an English title".
Anything I did wrong? Thanks!
1) In the /inc folder, I added a "languages" folder and then an "english" folder.
2) I added a file in the "english" folder, called "myplugin.lang.php" with something like $l['myplugin_title'] = "This is an English title";
3) At the beginning of the plugin file myplugin.php in /inc/plugins, I did the following:
global $lang;
$lang->load("myplugin");
4) And then I tried to access the string value like {$lang->myplugin_title} in the php code of myplugin.php
But, it doesn't work: on the page, it shows "{$lang->myplugin_title}" instead of "This is an English title".
Anything I did wrong? Thanks!