Browser and Locale-Dependent URI

Many resources depend on the Locale and, sometimes, the browser that a user is used to visit the Web page. For example, you need to use a larger font for Chinese characters to have better readability.

ZK can handle this for you automatically, if you specify the URL of the style sheet with "*". The algorithm is as follows.

  1. If there is one "*" is specified in an URI such as /my*.css, then "*" will be replaced with a proper Locale depending on the preferences of user's browser.For example, user's preferences is de_DE, then ZK searches /my_de_DE.css, /my_de.css, and /my.css one-by-one from your Web site, until any of them is found. If none of them is found, /my.css is still used.

  2. If two or more "*" are specified in an URI such as "/my*/lang*.css", then the first "*" will be replaced with "ie" for Internet Explorer, "saf" for Safari, and "moz" for other browsers[62]. Moreover, the last asterisk will be replaced with a proper Locale as described in the above step.In summary, the last asterisk represents the Locale, while the first asterisk represents the browser type.

  3. All other "*" are ignored.

Note: The lat asterisk that represents the Locale must be placed right before the first dot ("."), or at the end if no dot at all. Furthermore, no following slash (/) is allowed, i.e., it must be part of the filename, rather than a directory. If the last asterisk doesn't fulfill this constraint, it will be eliminated (not ignored).

For example, "/my/lang.css*" is equivalent to "/my/lang.css".

In other words, you can consider it as neutral to the Locale.

Tip: We can apply this rule to specify an URI depending on the browser type, but not depending on the Locale. For example, "/my/lang*.css*" will be replaced with "/my/langie.css" if Internet Explorer is the current user's browser.

In the following examples, we assume the preferred Locale is de_DE and the browser is Internet Explorer.

URI

Resources that are searched

/css/norm*.css

  1. /norm_de_DE.css

  2. /norm_de.css

  3. /norm.css

/css-*/norm*.css

  1. /css-ie/norm_de_DE.css

  2. /css-ie/norm_de.css

  3. /css-ie/norm.css

/img*/pic*/lang*.png

  1. /imgie/pic*/lang_de_DE.png

  2. /imgie/pic*/lang_de.png

  3. /imgie/pic*/lang.png

/img*/lang.gif

  1. /img/lang.gif

/img/lang*.gif*

  1. /img/langie.gif

/img*/lang*.gif*

  1. /imgie/lang*.gif



[62] In the future editions, we will use different codes for browsers other than Internet Explorer, Firefox and Safari.