Help to translate

How do I understand all this and translate?

%{src?%{dest?Forwarded:Incoming}:Outgoing} %{ipv6?%{ipv4?<var>IPv4</var> and <var>IPv6</var>:<var>IPv6</var>}:<var>IPv4</var>}%{proto?, protocol %{proto#%{next?, }%{item.types?<var class="cbi-tooltip-container">%{item.name}<span class="cbi-tooltip">ICMP with types %{item.types#%{next?, }<var>%{item}</var>}</span></var>:<var>%{item.name}</var>}}}%{mark?, mark <var%{mark.inv? data-tooltip="Match fwmarks except %{mark.num}%{mark.mask? with mask %{mark.mask}}.":%{mark.mask? data-tooltip="Mask fwmark value with %{mark.mask} before compare."}}>%{mark.val}</var>}%{dscp?, DSCP %{dscp.inv?<var data-tooltip="Match DSCP classifications except %{dscp.num?:%{dscp.name}}">%{dscp.val}</var>:<var>%{dscp.val}</var>}}%{helper?, helper %{helper.inv?<var data-tooltip="Match any helper except &quot;%{helper.name}&quot;">%{helper.val}</var>:<var data-tooltip="%{helper.name}">%{helper.val}</var>}}

Its basically expressions in one of the three forms:

  • %{expression?Text if true:Text if false} - Replace with "Text if true" when expression is set, otherwise replace with "Text if false". Both the true and the false variants can be omitted, e.g. %{expression?Text if true} will result in "Text if true" when expression is set, otherwise nothing. Another variant is %{expression?:Text if false} which will result in either the expression value when set or the text "Text if false".
  • %{expression#Loop text} - Repeat "Loop text" for each value in expression
  • %{expression} - Replace with the value of expression

There's also two special variables:

  • %{item} refers to the current list item being looped
  • %{next} a variable which is set to true for any list item except the first, this is mainly used to place list separators conditionally

For example the expression %{protocol#%{next?, }%{item}} with protocol = ["TCP", "UDP", "ICMP"] will result in "TCP, UDP, ICMP"

Broken into pieces and reformatted for clarity, the above block becomes the following text. The translatable parts are underlined.

For a real world example it might help to look at the russian translation which makes distinguishing the formatting code from the texts easy due to the use of the Cyrillic alphabet.

%{src?
  %{dest?
    Forwarded
  :
    Incoming
  }
:
  Outgoing
}

%{ipv6?
  %{ipv4?
    <var>IPv4</var> and <var>IPv6</var>
  :
    <var>IPv6</var>
  }
:
  <var>IPv4</var>
}

%{proto?
  , protocol 
  %{proto#
    %{next?
       ,
    }
    %{item.types?
      <var class="cbi-tooltip-container">
      %{item.name}
      <span class="cbi-tooltip">ICMP with types 
      %{item.types#
        %{next?
           , 
        }
        <var>
        %{item}
        </var>
      }
      </span></var>
    :
      <var>
      %{item.name}
      </var>
    }
  }
}

%{mark?
  , mark <var
  %{mark.inv? 
    data-tooltip="Match fwmarks except 
    %{mark.num}
    %{mark.mask? 
      with mask 
      %{mark.mask}
    }
    ."
  :
    %{mark.mask? 
      data-tooltip="Mask fwmark value with 
      %{mark.mask} 
      before compare."
    }
  }
  >
  %{mark.val}
  </var>
}

%{dscp?
  , DSCP 
  %{dscp.inv?
    <var data-tooltip="Match DSCP classifications except 
    %{dscp.num?:
      %{dscp.name}
    }
    ">
    %{dscp.val}
    </var>
  :
    <var>
    %{dscp.val}
    </var>
  }
}

%{helper?
  , helper 
  %{helper.inv?
    <var data-tooltip="Match any helper except &quot;
    %{helper.name}
    &quot;">
    %{helper.val}
    </var>
  :
    <var data-tooltip="
    %{helper.name}
    ">
    %{helper.val}
    </var>
  }
}

I don't understand much, but the Russian translation helped!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.