Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
b2820c7b
Commit
b2820c7b
authored
8 years ago
by
Jaime Pérez
Browse files
Options
Downloads
Patches
Plain Diff
Add some more examples to the sandbox, and restore missing information about current locale.
parent
f08c9381
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/sandbox.twig
+12
-6
12 additions, 6 deletions
templates/sandbox.twig
with
12 additions
and
6 deletions
templates/sandbox.twig
+
12
−
6
View file @
b2820c7b
...
@@ -28,7 +28,10 @@
...
@@ -28,7 +28,10 @@
</ul>
</ul>
<p>
Note that
<code>
gettext/gettext
</code>
<strong>
will become the default
</strong>
in SimpleSAMLphp 2.0.
<p>
Note that
<code>
gettext/gettext
</code>
<strong>
will become the default
</strong>
in SimpleSAMLphp 2.0.
Currently, you are using the following backend:
<code>
{{
localeBackend
}}
</code>
.
</p>
Currently, you are using the following backend:
<code>
{{
localeBackend
}}
</code>
.
</p>
<p>
Now, Twig allows you to translate strings in your templates. There are several ways to do that. If you want
<p>
This page is written in english only, but the examples used here are translated to several languages. The current
language is
<strong>
{{
currentLanguage
}}
</strong>
. Change to other languages to see the examples change.
</p>
<h4>
Usage examples
</h4>
<p>
Twig allows you to translate strings in your templates. There are several ways to do that. If you want
to translate the following text:
<em>
Hello, Untranslated World!
</em>
, you can do it with:
</p>
to translate the following text:
<em>
Hello, Untranslated World!
</em>
, you can do it with:
</p>
<ul>
<ul>
<li><em>
Inline trans tags
</em>
: using
<code>
{{
'{%'
}}
trans 'Hello, Untranslated World! %}
</code>
you would get
<li><em>
Inline trans tags
</em>
: using
<code>
{{
'{%'
}}
trans 'Hello, Untranslated World! %}
</code>
you would get
...
@@ -41,11 +44,14 @@
...
@@ -41,11 +44,14 @@
variables. Just use placeholders of the form
<code>
%variable%
</code>
in the place where the contents of the
variables. Just use placeholders of the form
<code>
%variable%
</code>
in the place where the contents of the
variables should be placed, and pass an associative array to the
<code>
trans
</code>
filter.
</p>
variables should be placed, and pass an associative array to the
<code>
trans
</code>
filter.
</p>
{%
set
variable
=
'Hello, %who%!'
%}
{%
set
variable
=
'Hello, %who%!'
%}
{%
set
who
=
{
'%who%'
:
'World'
}
%}
{%
set
world
=
'World'
|
trans
%}
{%
set
who
=
{
'%who%'
:
world
}
%}
<p>
If you have a variable with the text "
<code>
Hello, %who%!
</code>
" The code
<code>
{{
'{{'
}}
<p>
If you have a variable with the text "
<code>
Hello, %who%!
</code>
" The code
<code>
{{
'{{'
}}
variable|trans({'%who%': 'World' }) }}
</code>
will print "
{{
variable
|
trans
(
{
'%who%'
:
'World'
}
)
}}
". The array
variable|trans({'%who%': 'World' }) }}
</code>
will print "
{{
variable
|
trans
(
{
'%who%'
:
'World'
}
)
}}
". The array
can also be passed in a variable, so that
<code>
{{
'{{'
}}
variable|trans(who) }}
</code>
will also output
can also be passed in a variable, so that
<code>
{{
'{{'
}}
variable|trans(who) }}
</code>
will output
"
{{
variable
|
trans
(
who
)
}}
". Note that placeholders have names, so order is irrelevant, and can be changed
"
{{
variable
|
trans
(
who
)
}}
" when the variable
<code>
who
</code>
is defined as
<code>
{'%who%': world}
</code>
and
between translations.
</p>
<code>
world
</code>
is also a variable with the translation of the contents, for example,
<code>
{{
'{%'
}}
set world = 'World'|trans %}
</code>
. Note that placeholders have names, so order is irrelevant, and can be
changed between translations.
</p>
{%
endblock
content
%}
{%
endblock
content
%}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment