mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-26 10:59:18 +01:00
HTMLTemplateMultilang now also tries to use the locale helper method in WebServerRequest.
This commit is contained in:
parent
7e67160d53
commit
9ee96b25f8
@ -32,6 +32,8 @@
|
||||
#include "html_template_multilang.h"
|
||||
#include "core/object/object.h"
|
||||
|
||||
#include "modules/web/http/web_server_request.h"
|
||||
|
||||
Ref<HTMLTemplate> HTMLTemplateMultilang::get_template_for_locale(const StringName &p_locale) {
|
||||
Ref<HTMLTemplate> *t = _locales.getptr(p_locale);
|
||||
Ref<HTMLTemplate> ht;
|
||||
@ -79,10 +81,28 @@ void HTMLTemplateMultilang::set_locales(const Dictionary &p_dict) {
|
||||
}
|
||||
|
||||
String HTMLTemplateMultilang::_render(const Ref<WebServerRequest> &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<HTMLTemplate> *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<HTMLTemplate> *tp = _locales.getptr(locale);
|
||||
|
||||
if (tp) {
|
||||
|
Loading…
Reference in New Issue
Block a user