17. Translating messages in the content generated by a CSS style sheet

This is done as follows:

  1. All the messages to be translated must be enclosed in the _() pseudo-function. Example:

    .hello:before {
        content: _("Hello world!");
  2. An @translation at-rule pointing to a Java® property file must be added at the top of the CSS stylesheet. Example:

    @translation url(hello_en.properties);

    where file hello_en.properties contains:

    sayHello=Hello world!

    The name of the Java property file must end with "_LL.properties", where "LL" is a lower-case two-letter ISO 639 language code.

    This language code specifies the language of the messages contained in the Java property file. This language is English (code "en") in the case of the above example. Note that country variants (en-US, en-GB, fr-FR, fr-CA, etc) are not supported here.

    A relative URL is resolved against the URL of the CSS style sheet. In the example above, file hello_en.properties is expected to be found in the same directory as the CSS style sheet “including” it.

  3. An additional Java property file must be created for each available language.

    French example: hello_fr.properties:

    sayHello=Bonjour monde!

    German example: hello_de.properties:

    sayHello=Hallo Welt!

    These additional property files must use exactly the same property keys as those found in the reference property file.

    The reference property file is the file included in the CSS style sheet by the means of the @translation at-rule.

    In the example above, the reference property file is hello_en.properties. The author of this file has arbitrarily chosen to use property key "sayHello" to identify message "Hello world!" .

    These additional property files may be found in the same directory as the reference property file or, alternatively, they may be top level items contained in a JAR file referenced in the CLASSPATH. Alternate location example:

    $ jar tvf fr_translation.jar

    This alternate location is the one used by the "Translate XMLmind XML Editor" add-on.