A better way to include localized labels in WordPress plugins

there is no need to separate code from translatable labels. your plug_get_labels function suffers from the following issues

  1. Translation tools can show you the context in which the label is being used which helps in making a good translation faster. With your function you lose context.

  2. the use of such function encourage you to call it every time your code is being run and not only when a translation is needed. this might result in negative performance as loading the translation file and parsing it is relatively slow, and it makes you use extra memory (translation files are loaded only when a translation is required). of course if the number of translated strings is small there will not be a big impact.

Your json solution is truly bad. You lose the ability to use tools like poedit to do the translation because their use require that the first parameter to __ will be a literal string and not a variable.