Translates a string previously registered with pll_register_string in a given language. Translates a string previously registered with pll_register_stringĮchoes a translated string previously registered with pll_register_string ‘$multiline’ => (optional) if set to true, the translation text field will be multiline, defaults to false.‘$group’ => (optional) the group in which the string is registered, defaults to ‘polylang’.‘$string’ => (required) the string to translate.‘$name’ => (required) name provided for sorting convenience (ex: ‘myplugin’).Usage: pll_register_string( $name, $string, $group, $multiline ) It is possible to register empty strings (for example when they come from options) but they won’t appear in the list table. The function must be called on admin side (the functions.php file is OK for themes). pll_register_stringĪllows plugins to add their own strings in the “strings translation” panel. Returns the url of the homepage in the requested language, as a string. The parameter is optional and defaults to the current language if the function is called on frontend. ‘$slug’ => 2-letters code of the language.Returns the id of the translated term as integer. ![]() ‘$term_id’ => (required) id of the term you want the translation.Returns the category (or post tag) translation Returns the id of the translated post or page as integer. ‘$slug’ => (optional) 2-letters code of the language, defaults to current language.‘$post_id’ => (required) id of the post you want the translation.Returns either the full name, or the WordPress locale (just as the WordPress core function ‘get_locale’ or the slug ( 2-letters code) of the current language. ‘$value’ => (optional) either ‘name’ or ‘locale’ or ‘slug’, defaults to ‘slug’.If you need a function to get information about available languages, you should use pll_languages_list() instead. The function is meant to display a language switcher. => true if there is no available translation, false otherwise.=> true if this is the current language, false otherwise.The function will return an array of arrays, one array per language with the following entries: If the options are not enough, you can build your own custom language switcher using the ‘raw’ argument: $translations = pll_the_languages( array( 'raw' => 1 ) ) Important: You have to output yourself the ul tags if you don’t use the dropdown option. ‘raw’ => use this to create your own custom language switcher (default:0).‘post_id’ => if set, displays links to translations of the post (or page) defined by post_id (default: null).‘hide_current’=> hides the current language if set to 1 (default: 0).‘hide_if_no_translation’ => hides the language if no translation exists if set to 1 (default: 0).‘echo’ => echoes if set to 1, returns a string if set to 0 (default: 1).‘force_home’ => forces link to homepage if set to 1 (default: 0).‘hide_if_empty’ => hides languages with no posts (or pages) if set to 1 (default: 1). ![]() ![]() ‘show_flags’ => displays flags if set to 1 (default: 0).‘display_names_as’ => either ‘name’ or ‘slug’ (default: ‘name’).‘show_names’ => displays language names if set to 1 (default: 1).‘dropdown’ => displays a list if set to 0, a dropdown list if set to 1 (default: 0).Would anyone have an idea on what could be causing it? Thanks.IMPORTANT: when using one or more of these function, you *must* check for its existence before using it, otherwise your site will badly break with a fatal error at next Polylang update (as WordPress deletes the plugin when updating it). I even tried going to the language with the missing flag in the Language tab, clicking on edit, then entering the appropriate names for language, locale and selecting flags again, just to “reconfirm” that this is what the language should be showing, but when I save, it still shows that language wiothou the flag and the locale code.Īgain, all posts and pages display in their appropriate language as they should and the site works, so there is no problem with the actual languages versions themselves… except the missing flags. I have tried deactivating the Polylang plugin and reactivating, no success. And when I go to the Polylang plugin´s Languages tab, the same flags are missing there too… along with the names of their Locales. However, some of the flags in the Language Switcher widget are missing (3 flags missing, 5 displaying OK). ![]() All these work, I have no problems with displaying the various pages in their appropriate language. I am running Polylang (free) on a WordPress site with 8 language variants of each page.
0 Comments
Leave a Reply. |