Tag Conditions Language


Unique Approach to Defining Conditions

Defining conditions will enable users to include a tag into the translation process. This process is complicated when approached with the generally used XML XPATH Language. 
This language is more search - oriented, so searching for specific conditions becomes complicated.  We can not apply it using regular tools, because it requires content to meet XML validation rules.
When there is a mix of XML and HTML content (as is the case with websites), implementation of all the necessary directives for this language appears to be too time consuming.

We believe in a more simple solution. iLangl offers a flexible way to define conditions.
We believe that by separating tag identification and tag rule conditions we can significantly simplify condition language and make it highly flexible.

Conditions in general consist of three following parts:

  1. Value path - used to identify a path to a condition value

  2. Operation - the operation itself

  3. List of match values

It will be simple to parse this language when we set specific marks for the first and last parts of an expression. For example:  

  •  (Value Path) Operation {List of match values}
  • ([controls\value]\editor\name) in {\'Rich text editor\'}

Value Path

In order to check a condition, we have to get a value from somewhere in the content. "Value Path" serves this purpose. "Value Path" should be put in ‘(‘, ’)’ characters.
The most complex thing about the "Value Path" is how to identify which value to take, as it might be placed outside of a current content element. The good thing is that we have
already found the required element via "Value Path" and we can now begin value search starting from this element. Value path should be able to follow both
directions and each movement step should be put in '[', ']' characters. By default, navigation is "from left to right" (from parent to child, in tags tree) and it will start from a current element.

  • ']' Will tell the system to move "right to left" (from child to parent) and '[' will move "left to right" (from parent to child). 
  • You can also specify an attribute (attribute should be included in path and start with '@'), if not specified, system will take the value of a last node. 

 

Example: \value\@attribute

Operation

There are two operations we support:

  • in’ - means that a rule will be applied to a tag, if condition value matches any value from "List of match values"
  • 'not in’ - means that a rule will be applied to a tag, if condition value does not match any value from "List of match values"

List match values

List of match values should be enclosed within ‘{‘, ’}’ character. Each separate value should be enclosed within "\'" and separated by a comma.

Example:  {\'Rich text editor\', \'Image Viewer\'}

Condition Example

Let’s review an XML example:

//---------------------------------------------------

<controls>

<value>Translate me</value>

<editor>

             <name>Rich text editor</name>

 </editor>

</controls>

 //---------------------------------------------------

<controls> 

<value>Do not translate Me</value>

<editor>

             <name>Image Viewer</name>

 </editor>

</controls>

//---------------------------------------------------


Let’s define a new tag rule:

TagRule

{ 

           Name: ’value’

           Path: ‘controls\value’ 

           Translate: ’Yes’

           Condition: ‘([controls\value]\editor\name) in {\'Rich text editor\'}’

}


For the current tag rule and the XML above, system will find two tags for path = ‘controls\value’

  1. <value>Translate me</value>
  2. <value>Do not translate Me</value>


Now let’s take a look at the condition:

  • ([controls\value]\editor\name) in {\'Rich text editor\'}

For the first tag:

 

Step

Condition

Tag Tree

1: Search will start from a current root element

[controls\value]\editor\name

<controls>

<value>Translate me</value>

<editor>

  <name>Rich text editor</name>

  </editor>

</controls>

2. System will try to move "left to right", but it'll find character ‘]’,

which tells the system to move "right to left". it will navigate us to the "controls" tag

[controls\value]\editor\name

<controls>

 <value>Translate me</value>

 <editor>

  <name>Rich text editor</name>

  </editor>

</controls>

3. ‘[‘ symbol (which is to the right from the "controls" tag) tells the system to move "left to right".

[controls\value]\editor\name

<controls>

 <value>Translate me</value>

 <editor>

  <name>Rich text editor</name>

  </editor>

</controls>

4. System will continue to move to the right

[controls\value]\editor\name

<controls>

 <value>Translate me</value>

 <editor>

  <name>Rich text editor</name>

  </editor>

</controls>

 

As this is the last element and attribute is not specified, system will take content from this last node. The content here is "Rich text editor", which matches the condition we have.
The TagRule will be applied in this case to the <value> tag. However, this is not the case for the second <value> tag, where condition is not met, as the condition value is "Image Viewer".