The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MonLabo
Summary Activity Tracker Tasks Docs SCM Files Dokuwiki Continious Integration Listes Sympa

SCM Repository

authorHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Mon, 20 Jul 2020 23:00:36 +0000 (01:00 +0200)
committerHerve Suaudeau <herve.suaudeau@parisdescartes.fr>
Mon, 20 Jul 2020 23:00:36 +0000 (01:00 +0200)
includes/MonLabo-access-data.php
includes/MonLabo-generate-HTML.php
includes/MonLabo-shortcodes-publications.php
includes/MonLabo-shortcodes.php
includes/MonLabo-translate.php
readme.txt

index efdc5e5..698eac6 100644 (file)
@@ -367,6 +367,8 @@ class MonLabo_access_data {
                switch ( $lang ) {
                        case 'en-GB' :
                        case 'en-US' :
+                       case 'en_GB' :
+                       case 'en_US' :
                        case 'en' :
                                return 'name_en';
                        default : // fr
index e5c26c3..e902a99 100644 (file)
@@ -929,6 +929,7 @@ class MonLabo_generate_HTML {
                        default: //'fr-FR'
                                $team_name = MonLaboLib::to_html( $team_information->name_fr );
                }
+
                //Generate HTML
                //------------
                $colorText = '';
index 7815277..669b891 100644 (file)
@@ -184,7 +184,7 @@ class MonLabo_shortcodes_publications extends MonLabo_shortcodes_mother_class {
                $options0 = get_option( 'MonLabo_settings_group0' );
                $options4 = get_option( 'MonLabo_settings_group4' );
                $style_citation_reference = $options4['MonLabo_hal_publi_style'];
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
                $webservice_class_instance = New $webservice_class_name();
 
                // 1 - Récupération des paramètres et valeurs par défaut
@@ -488,9 +488,11 @@ class MonLabo_shortcodes_publications extends MonLabo_shortcodes_mother_class {
                // 2 - Détermination de la langue
                //-------------------------------
                if ( empty( $lang ) ) {
-                       switch ( get_bloginfo( 'language' ) ) {
+                       switch ( get_locale() ) {
                                case 'en-US':
                                case 'en-GB':
+                               case 'en_US':
+                               case 'en_GB':
                                        $languageHAL = 'Anglais';
                                        $languageShortcode = 'en';
                                        break;
@@ -502,6 +504,8 @@ class MonLabo_shortcodes_publications extends MonLabo_shortcodes_mother_class {
                        switch ( $lang ) {
                                case 'en-US':
                                case 'en-GB':
+                               case 'en_US':
+                               case 'en_GB':
                                case 'en':
                                case 'anglais':
                                case 'english':
@@ -878,10 +882,11 @@ class MonLabo_shortcodes_publications extends MonLabo_shortcodes_mother_class {
                switch ( $currentlang ) {
                        case 'en-US':
                        case 'en-GB':
+                       case 'en_US':
+                       case 'en_GB':
                                $lang = 'en';
                                break;
 
-                       case 'fr-FR':
                        default:
                                $lang = 'fr';
                                break;
index bd513b2..eb9998c 100644 (file)
@@ -186,7 +186,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                $a_afficher = '';
                $access_data = New MonLabo_access_data();
                $generate_HTML = New MonLabo_generate_HTML();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( (array) $atts, CASE_LOWER );
@@ -303,7 +303,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
 
                $access_data = New MonLabo_access_data();
                $generate_HTML = New MonLabo_generate_HTML();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( (array ) $atts, CASE_LOWER );
@@ -449,7 +449,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                $access_data = New MonLabo_access_data();
                $generate_HTML = New MonLabo_generate_HTML();
                $persons_information_by_category_and_team = array();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( (array ) $atts, CASE_LOWER );
@@ -551,10 +551,8 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                        $unit_ids = array_values( $units );
                        $unit_id = $unit_ids[0];
                        $unit_information = $access_data->get_unit_information( $unit_id );
-                       $unit_name =
-                               $access_data->get_unit_name( $unit_id, $currentlang )
-                               .'  -  '
-                               .$unit_information->code;
+                       $unitTextName = $access_data->get_unit_name( $unit_id, $currentlang );
+                       $unit_name = $unitTextName . '  -  ' . $unit_information->code;
                } else {
                        $unit_name = '';
                }
@@ -685,7 +683,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                        if ( !empty( $person_information ) ) {
                                $mentors_information= $access_data->get_mentors_information_for_a_person( $person_id );
                                $students_information = $access_data->get_students_information_for_a_person( $person_id );
-                               $currentlang = get_bloginfo( 'language' );
+                               $currentlang = get_locale( );
                                return $generate_HTML->person_panel(
                                        $person_information,
                                        $mentors_information,
@@ -728,7 +726,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                        $team_information = $access_data->get_team_information( $team_id );
                        if ( !empty( $team_information ) ) {
                                $leaders_information = $access_data->get_leaders_information_for_a_team( $team_id );
-                               $currentlang = get_bloginfo( 'language' );
+                               $currentlang = get_locale();
                                $thematics_name = $access_data->get_thematics_name_for_a_team( $team_id, $currentlang );
                                return $generate_HTML->team_panel(
                                        $team_information,
@@ -750,7 +748,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
        static function alumni_list( $atts ) {
                $a_afficher = '';
                $generate_HTML = New MonLabo_generate_HTML();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( (array) $atts, CASE_LOWER );
@@ -830,7 +828,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                $a_afficher = '';
                $access_data = New MonLabo_access_data();
                $generate_HTML = New MonLabo_generate_HTML();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( ( array) $atts, CASE_LOWER );
@@ -916,7 +914,7 @@ class MonLabo_shortcodes extends MonLabo_shortcodes_mother_class {
                $a_afficher = "";
                $access_data = New MonLabo_access_data();
                $generate_HTML = New MonLabo_generate_HTML();
-               $currentlang = get_bloginfo( 'language' );
+               $currentlang = get_locale();
 
                // normalize attribute keys, lowercase
                $atts = array_change_key_case( (array) $atts, CASE_LOWER );
index 3e35bde..f4f21ad 100644 (file)
@@ -29,13 +29,17 @@ class MonLabo_translate {
                //Step 1 : identify $language
                //---------------------------
                if ( '' === $language ) {
-                       $language = get_bloginfo( 'language' );
+                       $language = get_locale();
                }
                switch ( $language ) {
                        case 'en':
                        case 'en-GB':
-                       case 'en-US': $suffix = 'en'; break;
-                       default:          $suffix = 'fr'; break;
+                       case 'en-US':
+                       case 'en_GB':
+                       case 'en_US':
+                               $suffix = 'en'; break;
+                       default:
+                               $suffix = 'fr'; break;
                }
 
                //Step 2 : return custom text if defined
@@ -93,7 +97,7 @@ class MonLabo_translate {
                                                        'fr-FR'=> 'Statut' ),
                        );
                if ( '' === $language ) {
-                       $language = get_bloginfo( 'language' );
+                       $language = get_locale();
                }
                switch ( $language ) {
                        case 'en-GB':
index 068532f..5a1858f 100644 (file)
@@ -42,6 +42,7 @@ You can consult complete changelogs in file changelog.txt
 
 = 3.1 =
 * CODE: Convert text-domain and langage slug 'MonLabo' into 'mon-laboratoire' in order to be compatible with translate.wordpress.org
+* BUG: Solve potential errors of translations when blog language is different that page language.
 
 = 3.0.2 =
 * BUG : Suppress warnings with PHP 7.4