How to check if a localized string exist

Re: How to check if a localized string exist

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

The 'right' way to do this is demonstrated by lib/pluginlib.php. E.g.

        if (get_string_manager()->string_exists('type_' . $type . '_plural', 'core_plugin')) {
            // for most plugin types, their names are defined in core_plugin lang file
            return get_string('type_' . $type . '_plural', 'core_plugin');

        } else ...

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: How to check if a localized string exist

by Federico Ghigini -

Hi,
thanks for all the reply, soon I am testing it.

Tim: i have tried exactly your code, but it doesn't work. Could it be a bug?

Soon i'll post the code i'm using.

In reply to Federico Ghigini

Re: How to check if a localized string exist

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

If you go to Admin -> Plugins -> Overview, that page works, so the code I gave works when in context.

In reply to Tim Hunt

Re: How to check if a localized string exist

by Federico Ghigini -

Sorry,

probably i have misspelled some instruction.  The code posted by Tim and Matteo works great (and that code is very similar to the code in my first post).


Thanks to all!