Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Remove old i18n template syntaxes #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 1 addition & 86 deletions src/SSTemplateParser.peg
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class SSTemplateParser extends Parser implements TemplateParser
# primary matcher, and is used by all enclosing blocks, as well as a base for the top level.
# Any new template elements need to be included in this list, if they are to work.

Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | Include | ClosedBlock |
OpenBlock | MalformedBlock | MalformedBracketInjection | Injection | Text)+
*/
function Template_STR(&$res, $sub)
Expand Down Expand Up @@ -792,91 +792,6 @@ class SSTemplateParser extends Parser implements TemplateParser

/*!*

# Deprecated old-style i18n _t and sprintf(_t block tags. We support a slightly more flexible version than we used
# to, but just because it's easier to do so. It's strongly recommended to use the new syntax

# This is the core used by both syntaxes, without the block start & end tags

OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")?

# whitespace with a newline
N: / [\s\n]* /
*/
function OldTPart__construct(&$res)
{
$res['php'] = "_t(";
}

function OldTPart_QuotedString(&$res, $sub)
{
$entity = $sub['String']['text'];
if (strpos($entity ?? '', '.') === false) {
$res['php'] .= "\$scope->getOutputValue('I18NNamespace').'.$entity'";
} else {
$res['php'] .= "'$entity'";
}
}

function OldTPart_CallArguments(&$res, $sub)
{
$res['php'] .= ',' . $sub['php'];
}

function OldTPart__finalise(&$res)
{
$res['php'] .= ')';
}

/*!*

# This is the old <% _t() %> tag

OldTTag: "<%" < OldTPart > "%>"

*/
function OldTTag_OldTPart(&$res, $sub)
{
$res['php'] = $sub['php'];
}

/*!*

# This is the old <% sprintf(_t()) %> tag

OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>"

*/
function OldSprintfTag__construct(&$res)
{
$res['php'] = "sprintf(";
}

function OldSprintfTag_OldTPart(&$res, $sub)
{
$res['php'] .= $sub['php'];
}

function OldSprintfTag_CallArguments(&$res, $sub)
{
$res['php'] .= ',' . $sub['php'] . ')';
}

/*!*

# This matches either the old style sprintf(_t()) or _t() tags. As well as including the output portion of the
# php, this rule combines all the old i18n stuff into a single match rule to make it easy to not support these
# tags later

OldI18NTag: OldSprintfTag | OldTTag

*/
function OldI18NTag_STR(&$res, $sub)
{
$res['php'] = '$val .= ' . $sub['php'] . ';';
}

/*!*

# An argument that can be passed through to an included template

NamedArgument: Name:Word "=" Value:Argument
Expand Down
Loading
Loading