You are here

function _potx_skip_args in Translation template extractor 6.3

Same name and namespace in other branches
  1. 8 potx.inc \_potx_skip_args()
  2. 7.3 potx.inc \_potx_skip_args()
  3. 7 potx.inc \_potx_skip_args()
  4. 7.2 potx.inc \_potx_skip_args()

Helper to move past t() and format_plural() arguments in search of context.

Parameters

$here: The token before the start of the arguments

1 call to _potx_skip_args()
_potx_find_context in ./potx.inc
Helper to find the value for 'context' on t() and format_plural().

File

./potx.inc, line 1231
Extraction API used by the web and command line interface.

Code

function _potx_skip_args($here) {
  global $_potx_tokens;
  $nesting = 0;

  // Go through to either the end of the function call or to a comma
  // after the current position on the same nesting level.
  while (!($_potx_tokens[$here] == ',' && $nesting == 0 || $_potx_tokens[$here] == ')' && $nesting == -1)) {
    $here++;
    if (!is_array($_potx_tokens[$here])) {
      if ($_potx_tokens[$here] == ')') {
        $nesting--;
      }
      if ($_potx_tokens[$here] == '(') {
        $nesting++;
      }
    }
  }

  // If we run out of nesting, it means we reached the end of the function call,
  // so we skipped the arguments but did not find meat for looking at the
  // specified context.
  return $nesting == 0 ? $here : FALSE;
}