Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

String deprecation

From MoodleDocs

String deprecation is introduced in Moodle 2.8 to help minimize the language files but avoid accidental lost of translations by simply removing strings.

When string can be deprecated

It is not used anymore

But it is possible that it can be used in 3rd party plugins or even overlooked in core or standard plugins. Especially short generic strings such as 'hidden', 'yes', etc.

It was defined twice or in wrong component

Move it to the correct place and deprecate the old one in case somebody still uses it.

String identifier is incorrect or otherwise confusing for translators

For example, string 'hidden' in component 'grade'. Translator does not know if it refers to the grade item or grade category. In some languages it affects translation. Create a new string with correct identifier and deprecate the old one.

When string should be just removed

Removing functionality, error messages, etc. When string is definitely never used and should not be and nobody worries about lost translations.

How to deprecate a string

  • Add a file deprecated.txt (if does not exist) either in /lang/en/ or /componentfullpath/lang/en/
  • Add a line "identifier,fullcomponentname" to the end of this file
  • Move the string inside the existing language file to the end of the file under the comment "// Deprecated since Moodle X.Y" (this comment will help removing deprecated strings after two releases).

What to do if you get a debugging message

git blame is your friend. Run it on the corresponding lang/en/deprecated.txt and find the commit/issue that deprecated this string. If it was moved/renamed - use the new identifier.

If the string that you need was deleted you have the options:

  • Create an issue in Moodle to restore it from deprecated
  • Use another string
  • Copy the deprecated string into your plugin