File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,11 @@ protected AppController(@Nonnull PageContextManager context) {
113
113
protected @ Nonnull <T > MutableHttpResponse <T > affixHeaders (@ Nonnull MutableHttpResponse <T > response ,
114
114
@ Nonnull DynamicServingConfiguration config ) {
115
115
// first up: content language
116
- if (config .language ().isPresent ()) {
116
+ if (this .context .language ().isPresent ()) {
117
+ var lang = this .context .language ().get ();
118
+ logging .debug (format ("Affixing `Content-Language` header from context: '%s'." , lang ));
119
+ response .setAttribute ("language" , lang );
120
+ } else if (config .language ().isPresent ()) {
117
121
logging .debug (format ("Affixing `Content-Language` header from config: '%s'." , config .language ().get ()));
118
122
response .setAttribute ("language" , config .language ().get ());
119
123
this .context .language (config .language ());
Original file line number Diff line number Diff line change @@ -1494,6 +1494,19 @@ public boolean translate() {
1494
1494
return this ;
1495
1495
}
1496
1496
1497
+ /**
1498
+ * Return the language value set for the current render routine - i.e. bound to the current request cycle. This is
1499
+ * often driven by the user's browser settings.
1500
+ *
1501
+ * @return Current language for this request cycle.
1502
+ */
1503
+ public @ Nonnull Optional <String > language () {
1504
+ if (this .context .getLanguage ().length () > 0 ) {
1505
+ return Optional .of (this .context .getLanguage ());
1506
+ }
1507
+ return Optional .empty ();
1508
+ }
1509
+
1497
1510
/**
1498
1511
* Append an HTTP request header considered as part of the {@code Vary} header in the response. These values are de-
1499
1512
* duplicated before joining and affixing.
You can’t perform that action at this time.
0 commit comments