• Resolved tonfarbe

    (@tonfarbe)


    Hello,

    all of a sudden, since today, the Site language dropdown in Settings –> General is empty.
    In the dropdown I can see the installed languages but the section below Available is empty.
    I need to select a new language but can only chose from the already installed (and used) languages.

    When I setup a new Site and language yesterday, I could chose the language from the the list below Available.
    All I did since then was to paste the Hook ‘msls_options_get_available_languages’ in my functions.php only to learn that it will not work there. Then I removed the code from the functions.php. So the function.php is back to its original state.
    Could this have caused the plugin to not display the Available languages?

    Thanks in advance,
    tonfarbe

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter tonfarbe

    (@tonfarbe)

    Here’s a screenshot

    Plugin Author Dennis Ploetner

    (@realloc)

    Hello,

    please make sure that you return also the array languages that is incoming when you use the hook my_msls_options_get_available_languages to add a language.

    Here is an example of your specific use-case:

    /**
    * @param array $languages
    * @return string
    */
    function my_msls_options_get_available_languages( languages ) {
    if ( ! isset( $languages['en_IN'] ) ) {
    $languages['en_IN'] = 'English (India)';
    }
    return $languages;
    }
    add_filter( 'msls_options_get_available_languages', 'my_msls_options_get_available_languages' );

    As you can see, languages is an associative array. The keys are the language and region code and the value is the description.

    Thread Starter tonfarbe

    (@tonfarbe)

    Thanks for the quick reply!
    Where do I paste this hook?

    When I paste this hook in functions.php I get a ‘critical error’ in the backend.

    When I create a plugin, I get this warning: “Plugin could not be activated because it triggered a fatal error.”

    • This reply was modified 5 months, 3 weeks ago by tonfarbe.
    Plugin Author Dennis Ploetner

    (@realloc)

    I just realized that the above is not correct. This one is better:

    /**
    * @param array $languages
    * @return array
    */
    function my_msls_options_get_available_languages( $languages ) {
    if ( ! isset( $languages['en_IN'] ) ) {
    $languages['en_IN'] = 'English (India)';
    }
    return $languages;
    }
    add_filter( 'msls_options_get_available_languages', 'my_msls_options_get_available_languages' );
    Thread Starter tonfarbe

    (@tonfarbe)

    Thanks again.
    I wrote this hook in a plugin and was able to activate the plugin without any warnings.
    I guess now I should see the option of ‘Englisch (India)’ in the available languages dropdown.
    Unfortunately, this option isn’t shown.

    Plugin Author Dennis Ploetner

    (@realloc)

    I guess that this has to have also a language file in /wp-content/languages/ — at least as far as I remember.

    Thread Starter tonfarbe

    (@tonfarbe)

    Thanks, wer’re getting closer!
    I copied the en_NZ.po and renamed it to en_IN.po and en_IN.mo.
    Now finaly I can select the language en_IN in WordPress, but the code of the site still shows the href lang en-GB

    Plugin Author Dennis Ploetner

    (@realloc)

    Do you refer to the description that you can set in the settings of the plugin?

    Thread Starter tonfarbe

    (@tonfarbe)

    This is the language dropdown that extended by your hook (would prefer to have the listing ‘English (India)’ instead of ‘en_IN’:

    And this is the html code of the website that has the language en_IN assigned.
    The href lang is en-GB, but it needs to be en-IN.

    Thanks a lot for your superb support!

    Thread Starter tonfarbe

    (@tonfarbe)

    I have found a solution for my last problem with the wrong HTML lang attribute.
    There’s a plugin called ‘CHL-Change HTML Lang‘ that lets you enter the desired HTML lang attribute in WP –> Settings –> General.

    Thanks again for the great support!

    Plugin Author Dennis Ploetner

    (@realloc)

    Glad I could help! Have fun with the Multisite Language Switcher. ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.