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
3e9be61b
Commit
3e9be61b
authored
3 years ago
by
Thijs Kinkhorst
Browse files
Options
Downloads
Patches
Plain Diff
Initial version of tool to extract translatable strings from templates.
parent
536f71f2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/get-translatable-strings
+29
-0
29 additions, 0 deletions
bin/get-translatable-strings
lib/SimpleSAML/Utils/Translate.php
+42
-0
42 additions, 0 deletions
lib/SimpleSAML/Utils/Translate.php
lib/SimpleSAML/XHTML/Template.php
+9
-0
9 additions, 0 deletions
lib/SimpleSAML/XHTML/Template.php
with
80 additions
and
0 deletions
bin/get-translatable-strings
0 → 100755
+
29
−
0
View file @
3e9be61b
#!/usr/bin/php -q
<?php
use
SimpleSAML\Module
;
use
SimpleSAML\Utils
;
// This is the base directory of the SimpleSAMLphp installation
$baseDir
=
dirname
(
dirname
(
__FILE__
));
// Add library autoloader
require_once
(
$baseDir
.
'/lib/_autoload.php'
);
$transUtils
=
new
Utils\Translate
();
$sysUtils
=
new
Utils\System
();
$tempDirBase
=
$sysUtils
->
getTempDir
()
.
"/temptemplatestemp"
;
$outputSuffix
=
'/locales/en/LC_MESSAGES'
;
$modules
=
[
''
,
'core'
,
'admin'
,
'cron'
,
'exampleauth'
,
'multiauth'
,
'saml'
];
foreach
(
$modules
as
$module
)
{
$tempDir
=
$tempDirBase
.
"/"
.
$module
;
$transUtils
->
compileAllTemplates
(
$module
,
$tempDir
);
$domain
=
$module
?:
'messages'
;
$outputDir
=
$baseDir
.
(
$module
===
''
?
''
:
'/modules/'
.
$module
)
.
$outputSuffix
;
print
`xgettext --default-domain=$domain -p $outputDir --from-code=UTF-8 -j --no-location -ktrans -L PHP $tempDir/*/*.php`
;
}
// TODO: clean up workdir before/after run
// TODO: merge new strings into translated languages catalogs
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Utils/Translate.php
0 → 100644
+
42
−
0
View file @
3e9be61b
<?php
declare
(
strict_types
=
1
);
namespace
SimpleSAML\Utils
;
use
SimpleSAML\Configuration
;
use
SimpleSAML\XHTML\Template
;
/**
* @package SimpleSAMLphp
*/
class
Translate
{
/**
* Compile all Twig templates for the given $module into the given $outputDir.
* This is used by the translation extraction tool to find the translatable
* strings for this module in the compiled templates.
* $module can be '' for the main SimpleSAMLphp templates.
*/
public
function
compileAllTemplates
(
string
$module
,
string
$outputDir
):
void
{
$config
=
Configuration
::
loadFromArray
([
'template.cache'
=>
$outputDir
,
'module.enable'
=>
[
$module
=>
true
]]);
$baseDir
=
$config
->
getBaseDir
();
$tplSuffix
=
'/templates/'
;
$tplDir
=
$baseDir
.
(
$module
===
''
?
''
:
'modules/'
.
$module
)
.
$tplSuffix
;
$templateprefix
=
(
$module
===
''
?
''
:
$module
.
":"
);
foreach
(
new
\RecursiveIteratorIterator
(
new
\RecursiveDirectoryIterator
(
$tplDir
),
\RecursiveIteratorIterator
::
LEAVES_ONLY
)
as
$file
)
{
if
(
$file
->
isFile
())
{
$p
=
new
Template
(
$config
,
$templateprefix
.
str_replace
(
$tplDir
,
''
,
$file
->
getPathname
()));
$p
->
compile
();
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/XHTML/Template.php
+
9
−
0
View file @
3e9be61b
...
@@ -491,6 +491,15 @@ class Template extends Response
...
@@ -491,6 +491,15 @@ class Template extends Response
$this
->
data
[
'header'
]
=
$this
->
configuration
->
getValue
(
'theme.header'
,
'SimpleSAMLphp'
);
$this
->
data
[
'header'
]
=
$this
->
configuration
->
getValue
(
'theme.header'
,
'SimpleSAMLphp'
);
}
}
/**
* Helper function for locale extraction: just compile but not display
* this template. This is not generally useful, getContents() will normally
* compile and display the template in one step.
*/
public
function
compile
():
void
{
$this
->
twig
->
load
(
$this
->
twig_template
);
}
/**
/**
* Get the contents produced by this template.
* Get the contents produced by this template.
...
...
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