PHP Warning missing Argument 1 for __()

you get this error if you passed empty string or did not pass any argument to the __() function. You should check where you’ve used the __() function and check what value is being passed as argument.

Localize strings from db

There are multiple ways to do this: 1. Add multiple columns to the table with the strings you have to localize. E.g. one column for German, one for English, and so on. And then get the string from the appropriate column. This is perfect if the number of languages stays more or less constant (you … Read more

Localization of menu items

Get a WPML plugin – https://wpml.org/ Seriously, get it – it’s the most complete solution for multilingual WP site. You can write your own code to translate menu items, but it is not worth it.

What about Deferring a localized script?

The solution is basically from this SO post: When wordpress “localizes” a script, what it does is has php print out <script></script> tags with javascript objects in them that are then accessible within the DOM to the scripts you are “sending” the parameters to. If I understand correctly, the extension of WP_Scripts simple adds a … Read more

How to ‘manually’ load translations/test domain outside theme context?

Already found out: load_textdomain(‘my-text-domain’, TEMPLATEPATH . ‘/languages/’. $my_locale . ‘.mo’); In some cases it could be useful to restore the previous text domain, so we should make a backup. An old function I had hidden in my code that does all, is this one: function __2($string, $textdomain, $locale){ global $l10n; if(isset($l10n[$textdomain])) $backup = $l10n[$textdomain]; load_textdomain($textdomain, … Read more