From 982a9a5919bdb48adced73ce9570a12cefdccace Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 9 Jun 2020 14:16:24 +0200 Subject: [PATCH] MDL-68985 core_h5p: fix issue with composed code languages Composed code languages, such as 'Spanish, Mexican' are different in H5P and Moodle: - In H5P, they use '-' to separate the language from the country. For instance: es-mx. - However, in Moodle, they have '_' instead of '-'. For example: es_mx. --- h5p/classes/local/library/handler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/h5p/classes/local/library/handler.php b/h5p/classes/local/library/handler.php index c9c538991b6..61089692120 100644 --- a/h5p/classes/local/library/handler.php +++ b/h5p/classes/local/library/handler.php @@ -134,6 +134,10 @@ abstract class handler { $value = null; $h5pversion = static::get_h5p_version(); $component = 'h5plib_v' . $h5pversion; + // Composed code languages, such as 'Spanish, Mexican' are different in H5P and Moodle: + // - In H5P, they use '-' to separate language from the country. For instance: es-mx. + // - However, in Moodle, they have '_' instead of '-'. For instance: es_mx. + $language = str_replace('-', '_', $language); if (get_string_manager()->string_exists($identifier, $component)) { $defaultmoodlelang = 'en'; // In Moodle, all the English strings always will exist because they have to be declared in order to let users