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
6da0e170
Commit
6da0e170
authored
8 years ago
by
Jaime Pérez
Browse files
Options
Downloads
Patches
Plain Diff
Make PHP's native gettext implementation work with twig.
parent
dca36184
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
lib/SimpleSAML/Locale/Localization.php
+35
-13
35 additions, 13 deletions
lib/SimpleSAML/Locale/Localization.php
with
35 additions
and
13 deletions
lib/SimpleSAML/Locale/Localization.php
+
35
−
13
View file @
6da0e170
...
@@ -28,9 +28,19 @@ class Localization
...
@@ -28,9 +28,19 @@ class Localization
const
DEFAULT_DOMAIN
=
'ssp'
;
const
DEFAULT_DOMAIN
=
'ssp'
;
/**
/**
*
Default 1i18n backend
*
Old internationalization backend included in SimpleSAMLphp.
*/
*/
const
DEFAULT_I18NBACKEND
=
'SimpleSAMLphp'
;
const
OLD_I18N_BACKEND
=
'SimpleSAMLphp'
;
/**
* PHP's native internationalization backend (gettext).
*/
const
NATIVE_I18_NBACKEND
=
'ext-intl'
;
/**
* An internationalization backend implemented purely in PHP.
*/
const
PHP_I18N_BACKEND
=
'gettext/gettext'
;
/*
/*
* The default locale directory
* The default locale directory
...
@@ -159,7 +169,7 @@ class Localization
...
@@ -159,7 +169,7 @@ class Localization
*/
*/
public
function
isI18NBackendDefault
()
public
function
isI18NBackendDefault
()
{
{
if
(
$this
->
i18nBackend
===
$this
::
DEFAULT
_I18NBACKEND
)
{
if
(
$this
->
i18nBackend
===
$this
::
OLD
_I18N
_
BACKEND
)
{
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -171,14 +181,20 @@ class Localization
...
@@ -171,14 +181,20 @@ class Localization
*/
*/
private
function
setupL10N
()
private
function
setupL10N
()
{
{
// use old system
switch
(
$this
->
i18nBackend
)
{
if
(
$this
->
isI18NBackendDefault
())
{
case
self
::
OLD_I18N_BACKEND
:
// use old system
\SimpleSAML\Logger
::
debug
(
"Localization: using old system"
);
\SimpleSAML\Logger
::
debug
(
"Localization: using old system"
);
return
;
return
;
case
self
::
NATIVE_I18_NBACKEND
:
putenv
(
'LC_ALL='
.
$this
->
langcode
);
putenv
(
'LANGUAGE='
.
$this
->
langcode
);
setlocale
(
LC_ALL
,
$this
->
langcode
);
// continue to add the domain
default
:
// setup default domain
$this
->
addDomain
(
$this
->
localeDir
,
self
::
DEFAULT_DOMAIN
);
$this
->
activateDomain
(
self
::
DEFAULT_DOMAIN
);
}
}
// setup default domain
$this
->
addDomain
(
$this
->
localeDir
,
self
::
DEFAULT_DOMAIN
);
$this
->
activateDomain
(
self
::
DEFAULT_DOMAIN
);
}
}
/**
/**
...
@@ -197,9 +213,15 @@ class Localization
...
@@ -197,9 +213,15 @@ class Localization
*/
*/
public
function
activateDomain
(
$domain
)
public
function
activateDomain
(
$domain
)
{
{
\SimpleSAML\Logger
::
debug
(
"Localization: activate domain"
);
if
(
$this
->
i18nBackend
===
'ext-intl'
)
{
$this
->
loadGettextGettextFromPO
(
$domain
);
bindtextdomain
(
$domain
,
$this
->
localeDir
);
$this
->
currentDomain
=
$domain
;
bind_textdomain_codeset
(
$domain
,
'UTF-8'
);
textdomain
(
$domain
);
}
else
{
\SimpleSAML\Logger
::
debug
(
"Localization: activate domain"
);
$this
->
loadGettextGettextFromPO
(
$domain
);
$this
->
currentDomain
=
$domain
;
}
}
}
...
...
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