L20n/Features/Conditional blocks

From MozillaWiki
< L20n‎ | Features
Jump to: navigation, search


allow for entities to be enabled only for some screen sizes, operating systems, languages etc.


Basically there are two concepts here. One is to group a list of entities into some form of "if" block, another is to make @import command work only when a pattern matches.

Use cases here are entities that are used only for a given operating system (mac or win only), or different entities for different screen sizes (if screen width is below 480, use shorter entities).

For the block cases, the syntax might look similar to this:

if (@width<600 && @locale="pl") {
  <title "Short text">
  <windowDesc "About this app">

of course it's entirely possible to achieve the same with index and globals:

<title[@width<600 ? 'long' : 'short'] {
  short: "Settings",
  long: "Settings Manager"

This syntax would also allow for import command to be encapsulated within such a conditional block.


Conditional blocks are at odds with completeness checking. One solution might be to require that the entities in a block are also defined in their default form outside of the block. In this scenario, it might even make sense to use a different keyword, like overload instead of if.

We want to see if there will be a need for grouping variations of entities under a condition. For now, we propose to put this feature on hold. Indexes (like title[@width<600 ? 'long' : 'short']) give us the same functionality and actually have a nice feature to them: the entity is defined in one place only.


This is needed for multilocale resources (Gaia)