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.
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.
No it does not work, people that will need to translate the string will not be able to use the automated tools they usually use to extract the strings that need translation. And yes, it is always bad.
I have to use this PHP function to get the list of files contained in the language directory of the plugin : scandir($plg_dir.”/language”);
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
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.
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
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
create a language file with the i18n string en_US, also the same procedure how with other languages, if the original is english. WordPress set the language key to en_US, if the key is empty in the wp-config.php. Use the plugin Codestyling Localization for easy create the language files inside your WordPress Install.
With honor to @Wyck’s link, I managed to add a language variable by adding an action hook to init and set the locale into cookie using PHP’s setcookie() function. For details, visit: Setting custom cookies in WordPress
Use the CS Localization plugin and generate the po/mo files, thats all. Save the file also in the repo of git and ready. The performance of the theme is not so high, if you have the strings inside the php-files, but only so it is possible to create different languages for the themes. mo/po files … Read more