Anonymous
Получите перевод на Moodle, используя «get_string» для определенного языка
Сообщение
Anonymous » 17 фев 2025, 07:24
Переведите Moodle, используя «get_string» для определенного языка. Я пытаюсь получить перевод моего блока плагина на Moodle на определенном языке. Но я не могу. Вот пример кода: < /p>
Код: Выделить всё
public static function course_lesson_created(\mod_lesson\event\page_created $event)
{
global $DB;
$event_data = $event->get_data();
// Get the course ID from the event data
if (isset($event_data['target']) && $event_data['target'] == "page") {// if lesson page
$objectid = $event_data['objectid'];
// Query the database to get the lesson page
$lessonPage = $DB->get_record('lesson_pages', ['id' => $objectid], '*', MUST_EXIST);
$lesson = $DB->get_record('lesson', ['id' => $lessonPage->lessonid], '*', MUST_EXIST);
$course_module = $DB->get_record('course_modules', ['id' => $event_data['contextinstanceid']], '*', MUST_EXIST);
$response = self::create_MoodleContentDetail(
$lessonPage->title,
$lesson->intro,
$event_data["action"],
"lesson",
"" . get_string('lessontitle', 'block_smartteacher', null, $course_module->lang) . ": {$lessonPage->title}" .
"" . get_string('lessondescription', 'block_smartteacher', null, $course_module->lang) . ": {$lesson->intro}" .
"" . get_string('lessoncontent', 'block_smartteacher', null, $course_module->lang) . ": {$lessonPage->contents}",
$course_module->lang,
$course_module->course, // courseId
$course_module->module, // moduleTypeId
$course_module->id, // moduleId
$course_module->section // sectionId
);
// var_dump(json_encode($event_data));
// var_dump(json_encode($response));
/* var_dump(get_string('lessoncontent', 'block_smartteacher', null, $course_module->lang));
var_dump(get_string('lessoncontent', 'block_smartteacher', null, "ar"));
var_dump(get_string('lessoncontent', 'block_smartteacher', null, "en")); */
// var_dump($course_module->lang == "ar");
// var_dump($course_module->lang == "en");
// var_dump($course_module->lang == "ar" ? "ar" : "en");
// die();
}
}
< /code>
Я не так get_string ('messontitle', 'block_smartteacher', null, $ course_module-> lang) < /code>? "AR"
Подробнее здесь:
https://stackoverflow.com/questions/793 ... c-language
1739766264
Anonymous
Переведите Moodle, используя «get_string» для определенного языка. Я пытаюсь получить перевод моего блока плагина на Moodle на определенном языке. Но я не могу. Вот пример кода: < /p> [code] public static function course_lesson_created(\mod_lesson\event\page_created $event) { global $DB; $event_data = $event->get_data(); // Get the course ID from the event data if (isset($event_data['target']) && $event_data['target'] == "page") {// if lesson page $objectid = $event_data['objectid']; // Query the database to get the lesson page $lessonPage = $DB->get_record('lesson_pages', ['id' => $objectid], '*', MUST_EXIST); $lesson = $DB->get_record('lesson', ['id' => $lessonPage->lessonid], '*', MUST_EXIST); $course_module = $DB->get_record('course_modules', ['id' => $event_data['contextinstanceid']], '*', MUST_EXIST); $response = self::create_MoodleContentDetail( $lessonPage->title, $lesson->intro, $event_data["action"], "lesson", "" . get_string('lessontitle', 'block_smartteacher', null, $course_module->lang) . ": {$lessonPage->title}" . "" . get_string('lessondescription', 'block_smartteacher', null, $course_module->lang) . ": {$lesson->intro}" . "" . get_string('lessoncontent', 'block_smartteacher', null, $course_module->lang) . ": {$lessonPage->contents}", $course_module->lang, $course_module->course, // courseId $course_module->module, // moduleTypeId $course_module->id, // moduleId $course_module->section // sectionId ); // var_dump(json_encode($event_data)); // var_dump(json_encode($response)); /* var_dump(get_string('lessoncontent', 'block_smartteacher', null, $course_module->lang)); var_dump(get_string('lessoncontent', 'block_smartteacher', null, "ar")); var_dump(get_string('lessoncontent', 'block_smartteacher', null, "en")); */ // var_dump($course_module->lang == "ar"); // var_dump($course_module->lang == "en"); // var_dump($course_module->lang == "ar" ? "ar" : "en"); // die(); } } < /code> Я не так get_string ('messontitle', 'block_smartteacher', null, $ course_module-> lang) < /code>? "AR" [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/79349547/get-translation-on-moodle-using-get-string-for-a-specific-language[/url]