[wp-hackers] Settings API -- Translation issues

Otto otto at ottodestruct.com
Sun Sep 30 15:31:02 UTC 2012

On Sun, Sep 30, 2012 at 9:13 AM, wpmidia lab <wpmidia at gmail.com> wrote:
> I'm having difficulty translating the options page of my plugin, using
> Settings API.
> Only the menu item and the page title are translated. Form fields
> configuration (an array), do not translate.
> What am I doing wrong?

You're defining these options and translating those strings into a
variable in the main body of the plugin (inside global scope), but not
calling the load_plugin_textdomain call until the 'init' action hook.
This means that your strings are being translated before your
text-domain loads, because the plugin load happens before init runs.

Move the definition of the settings (and translation of those strings)
into a function, then call that from your init function *after* you've
loaded your text-domain.


More information about the wp-hackers mailing list