Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#54086 new defect (bug)

bloginfo language issue

Reported by: kukac7's profile kukac7 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Networks and Sites Keywords: reporter-feedback needs-patch
Focuses: multisite Cc:

Description

hi,

the code snippet below only returns the name of the blog well, not the language, it is always the same.
even though the language is changed in the site admin settings.

<?php
$sites = get_sites();

foreach ( $sites as $site ) {
        switch_to_blog( $site->blog_id );
        echo get_bloginfo( 'name' );
        echo get_bloginfo( 'language' );
        restore_current_blog();
}

Change History (5)

#1 follow-up: @spacedmonkey
3 years ago

Hello @kukac7, welcome to track.

language can be tricky to workout. determine_locale and get_locale are complex functions.

If you are looking for the site language, have you tried calling echo get_option( 'WPLANG' ); instead of echo get_bloginfo( 'language' ). This might work better in this context.

#2 @spacedmonkey
3 years ago

  • Keywords reporter-feedback needs-patch added
  • Version changed from 5.8 to 3.0

#3 in reply to: ↑ 1 ; follow-up: @kukac7
3 years ago

Replying to spacedmonkey:

Hello @kukac7, welcome to track.

language can be tricky to workout. determine_locale and get_locale are complex functions.

If you are looking for the site language, have you tried calling echo get_option( 'WPLANG' ); instead of echo get_bloginfo( 'language' ). This might work better in this context.

hi,

i have tried this now, but my problem is that in the general settings i have saved the language on the selected site, but with the network site settings the WPLANG field is empty on the selected site.
interesting.
and if i write in the WPLANG field, save, but it remains blank again.

#4 in reply to: ↑ 3 @kukac7
3 years ago

Replying to kukac7:

Replying to spacedmonkey:

Hello @kukac7, welcome to track.

language can be tricky to workout. determine_locale and get_locale are complex functions.

If you are looking for the site language, have you tried calling echo get_option( 'WPLANG' ); instead of echo get_bloginfo( 'language' ). This might work better in this context.

hi,

i have tried this now, but my problem is that in the general settings i have saved the language on the selected site, but with the network site settings the WPLANG field is empty on the selected site.
interesting.
and if i write in the WPLANG field, save, but it remains blank again.

very strange.
by default hu_HU is the language of the network.
if i set it to en_EN on one site, WPLANG is empty.
however, de_DE, the ru_RU language, works.

#5 @henry.wright
3 years ago

@kukac7 my understanding is WPLANG is empty when the value is en_US. en_US seems to be the default and that may explain why the value is absent

Note: See TracTickets for help on using tickets.