lexicon
Locale Selection
Every time a Niagara VM is started it attempts to select a default locale using the host operating system. The OS default may be overridden via the command line flag “-locale:lang”, where lang is the locale code. The default locale of the VM may be accessed via the Sys.getLanguage() API.
When the workbench is launched as a desktop application it follows the rules above to select it’s locale. Once selected the entire workbench uses that locale independent of user accounts used to log into stations.
LocaleFilter
N4 introduces several usability and accuracy improvements for resolving the user’s locale. There are three possible ways for Niagara to determine the user’s locale for web browser access to station:
- If the request has been authenticated, examine the BUser’s langauge;
- If not, then check for an ‘Accept Language’ header. If the header has been defined, delegate Locale determination to the web containers implementation. Jetty does an excellent job of gleaning ‘high quality’ languages from the header;
- As a last resort, use Sys#getLanguage;
下面代码摘自LocaleServletRequest:
public Locale getLocale() {
if (this.loc == null) {
Principal principal = this.getUserPrincipal();
if (principal != null && principal instanceof BUser) {
String userLang = ((BUser)principal).getLanguage();
if (!userLang.equals("")) {
this.loc = new Locale(userLang);
}
}
if (this.loc == null && this.getHeader("Accept-Language") != null) {
this.loc = this.getRequest().getLocale();
}
if (this.loc == null) {
this.loc = new Locale(Sys.getLanguage());
}
}
return this.loc;
}
Lexicon Module Builder
在这里可以把!lexicon目录下的多个lexicon文件打包成Niagara的模块,从而便于通过platform Software Manager 将上面生成的lexicon模块安装到JACE控制器上。
Brand Pattern
It is used by the Lexicon system at runtime, and will check the brand pattern against the brand of the current system (JACE or workbench), accepting only lexicons that match the pattern.
The Niagara pattern matching will match any series of characters with “*”, or match a single character to “?”. So brand patterns “?ridium”, “tri?ium”, “tri*” should all match “tridium”.