arturobernalg opened a new pull request, #596:
URL: https://github.com/apache/jspwiki/pull/596
Adapts the LanguagePlugin that @udittmer attached to JSPWIKI-530. It shows
the block of the plugin body that matches the Accept-Language header of the
browser:
```
[{LanguagePlugin
:de:Willkommen:: :en:Welcome:: :else:Fallback::}]
```
What changed from the attached file:
- The chosen text is rendered as wiki markup, like IfPlugin does. The
attached version returned it as it was, so HTML in a block was not escaped,
even with allowHTML off. A test covers it.
- The quality values of the header are followed, so `en;q=0.3, de;q=0.9`
gives German. Tags with q=0 and the wildcard are ignored.
- Only the language is compared, so `de` matches `de-AT`.
- A call without a body shows nothing instead of failing with a null
pointer. A request without the header shows the else block.
- License header, the jakarta imports of master, display name and snippet
example for the editor suggestions, and registration in jspwiki_module.xml. The
log4j 1 logging is gone, the plugin does not log.
Tests: LanguagePluginTest, 10 tests, rendering a page for different
Accept-Language headers. The escaping test fails if the text is returned
unrendered. I also built the war and checked it on a running wiki with seven
headers (de, de-AT, quality values, fallback to the next language, else block,
no header, a language without a block); the right block was shown each time.
Not tested: the whole jspwiki-main suite, real browsers (only the plain
header), and the translations of the display name, which fall back to English.
Limits, also in the javadoc: a block ends at the first `::`, so its text
cannot contain it, and the body must follow a blank line, a call all in one
line shows nothing.
@udittmer, could you review this? The plugin is yours, I only changed what
is listed above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]