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
e8c7f1c5
Commit
e8c7f1c5
authored
9 years ago
by
Hanne Moa
Browse files
Options
Downloads
Patches
Plain Diff
Hook up new localization with twig.i18n
parent
9243d9b3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/SimpleSAML/Locale/Language.php
+25
-0
25 additions, 0 deletions
lib/SimpleSAML/Locale/Language.php
lib/SimpleSAML/XHTML/Template.php
+15
-1
15 additions, 1 deletion
lib/SimpleSAML/XHTML/Template.php
templates/sandbox.twig
+2
-0
2 additions, 0 deletions
templates/sandbox.twig
with
42 additions
and
1 deletion
lib/SimpleSAML/Locale/Language.php
+
25
−
0
View file @
e8c7f1c5
...
@@ -115,6 +115,17 @@ class Language
...
@@ -115,6 +115,17 @@ class Language
'eu'
=>
'Euskara'
,
// Basque
'eu'
=>
'Euskara'
,
// Basque
);
);
/**
* A mapping of SSP languages to locales
*
* @var array
*/
private
$languagePosixMapping
=
array
(
'no'
=>
'nb_NO'
,
'en'
=>
'en_US'
,
'nn'
=>
'nn_NO'
,
);
/**
/**
* Constructor
* Constructor
...
@@ -138,6 +149,20 @@ class Language
...
@@ -138,6 +149,20 @@ class Language
}
}
/*
* Rename to non-idiosyncratic language code
*
* @param string $language Language code for the language to rename, if neccesary.
*/
public
function
getPosixLanguage
(
$language
)
{
if
(
isset
(
$this
->
languagePosixMapping
[
$language
]))
{
return
$this
->
languagePosixMapping
[
$language
];
}
return
$language
;
}
/**
/**
* This method will set a cookie for the user's browser to remember what language was selected.
* This method will set a cookie for the user's browser to remember what language was selected.
*
*
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/XHTML/Template.php
+
15
−
1
View file @
e8c7f1c5
...
@@ -24,6 +24,13 @@ class SimpleSAML_XHTML_Template
...
@@ -24,6 +24,13 @@ class SimpleSAML_XHTML_Template
*/
*/
private
$translator
;
private
$translator
;
/**
* The localization backend
*
* @var \SimpleSAML\Locale\Localization
*/
private
$localization
;
/**
/**
* The configuration to use in this template.
* The configuration to use in this template.
*
*
...
@@ -65,6 +72,8 @@ class SimpleSAML_XHTML_Template
...
@@ -65,6 +72,8 @@ class SimpleSAML_XHTML_Template
// TODO: do not remove the slash from the beginning, change the templates instead!
// TODO: do not remove the slash from the beginning, change the templates instead!
$this
->
data
[
'baseurlpath'
]
=
ltrim
(
$this
->
configuration
->
getBasePath
(),
'/'
);
$this
->
data
[
'baseurlpath'
]
=
ltrim
(
$this
->
configuration
->
getBasePath
(),
'/'
);
$this
->
translator
=
new
SimpleSAML\Locale\Translate
(
$configuration
,
$defaultDictionary
);
$this
->
translator
=
new
SimpleSAML\Locale\Translate
(
$configuration
,
$defaultDictionary
);
$this
->
localization
=
new
\SimpleSAML\Locale\Localization
(
$configuration
);
$this
->
useTwig
=
$this
->
setupTwig
();
$this
->
twig
=
$this
->
setupTwig
();
$this
->
twig
=
$this
->
setupTwig
();
}
}
...
@@ -146,7 +155,12 @@ class SimpleSAML_XHTML_Template
...
@@ -146,7 +155,12 @@ class SimpleSAML_XHTML_Template
return
null
;
return
null
;
}
}
return
new
\Twig_Environment
(
$loader
,
array
(
'cache'
=>
$cache
,
'auto_reload'
=>
$auto_reload
));
$twig
=
new
\Twig_Environment
(
$loader
,
array
(
'cache'
=>
$cache
,
'auto_reload'
=>
$auto_reload
));
if
(
$this
->
localization
->
i18nBackend
==
'twig.i18n'
)
{
$this
->
localization
->
activateDomain
(
'ssp'
);
$twig
->
addExtension
(
new
\Twig_Extensions_Extension_I18n
());
}
return
$twig
;
}
}
/*
/*
...
...
This diff is collapsed.
Click to expand it.
templates/sandbox.twig
+
2
−
0
View file @
e8c7f1c5
...
@@ -2,5 +2,7 @@
...
@@ -2,5 +2,7 @@
{%
block
content
%}
{%
block
content
%}
<p>
This page exists as a sandbox to play with twig without affecting anything else. The template is in ./templates.
</p>
<p>
This page exists as a sandbox to play with twig without affecting anything else. The template is in ./templates.
</p>
<p>
{{
sometext
}}
</p>
<p>
{{
sometext
}}
</p>
<p>
Original: Hello, Untranslated World!
</p>
<p>
Translated:
{%
trans
'Hello, Untranslated World!'
%}
</p>
<p>
Current locale set:
{{
currentLanguage
}}
</p>
<p>
Current locale set:
{{
currentLanguage
}}
</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