diff --git a/modules/web/html/html_template_multilang.cpp b/modules/web/html/html_template_multilang.cpp
index 6ab103261..f616738db 100644
--- a/modules/web/html/html_template_multilang.cpp
+++ b/modules/web/html/html_template_multilang.cpp
@@ -32,6 +32,8 @@
#include "html_template_multilang.h"
#include "core/object/object.h"
+#include "modules/web/http/web_server_request.h"
+
Ref HTMLTemplateMultilang::get_template_for_locale(const StringName &p_locale) {
Ref *t = _locales.getptr(p_locale);
Ref ht;
@@ -79,10 +81,28 @@ void HTMLTemplateMultilang::set_locales(const Dictionary &p_dict) {
}
String HTMLTemplateMultilang::_render(const Ref &p_request, const Dictionary &p_data) {
+ if (p_request.is_valid()) {
+ StringName locale = p_request->get_locale();
+
+ if (locale == StringName()) {
+ return HTMLTemplate::_render(p_request, p_data);
+ }
+
+ Ref *tp = _locales.getptr(locale);
+
+ if (tp) {
+ return (*tp)->render(p_request, p_data);
+ }
+ }
+
const Variant *pp = p_data.getptr("locale");
if (pp) {
StringName locale = *pp;
+ if (locale == StringName()) {
+ return HTMLTemplate::_render(p_request, p_data);
+ }
+
Ref *tp = _locales.getptr(locale);
if (tp) {