Skip to content
Snippets Groups Projects
Commit 1b1beb98 authored by Hanne Moa's avatar Hanne Moa
Browse files

Start on new localization glue system

parent 227e83f8
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Glue to connect one or more translation/locale systems to the rest
*
* @author Hanne Moa, UNINETT AS. <hanne.moa@uninett.no>
* @package SimpleSAMLphp
*/
namespace SimpleSAML\Locale;
class Localization
{
/**
* The configuration to use.
*
* @var \SimpleSAML_Configuration
*/
private $configuration;
/**
* The default gettext domain.
*/
private $domain = 'ssp';
/*
* The locale directory
*/
private $localeDir;
/**
* Constructor
*
* @param \SimpleSAML_Configuration $configuration Configuration object
*/
public function __construct(\SimpleSAML_Configuration $configuration)
{
$this->configuration = $configuration;
$this->localeDir = $this->configuration->resolvePath('locales');
$this->language = new Language($configuration);
$this->i18nBackend = $this->configuration->getString('language.i18n.backend', null);
$this->setupL10N();
}
private function setupL10N() {
// use old system
if (is_null($this->i18nBackend)) {
return;
}
$encoding = "UTF-8";
$langcode = $this->language->getPosixLanguage($this->language->getLanguage());
// use gettext and Twig.I18n
if ($this->i18nBackend == 'twig.i18n') {
putenv('LC_ALL='.$langcode);
setlocale(LC_ALL, $langcode);
bindtextdomain($this->domain, $this->localeDir);
bind_textdomain_codeset($this->domain, $encoding);
}
}
public function activateDomain($domain)
{
if ($this->i18nBackend == 'twig.i18n') {
textdomain($domain);
}
}
public function restoreDefaultDomain()
{
if ($this->i18nBackend == 'twig.i18n') {
textdomain($this->domain);
}
}
}
File added
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-03-01 14:40+0100\n"
"PO-Revision-Date: 2016-03-01 14:42+0100\n"
"Last-Translator: Hanne Moa <hanne.moa@uninett.no>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: en\n"
msgid "Hello, Untranslated World!"
msgstr "Hello, Translated World!"
en
\ No newline at end of file
File added
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-03-01 14:40+0100\n"
"PO-Revision-Date: 2016-03-01 14:45+0100\n"
"Last-Translator: Hanne Moa <hanne.moa@uninett.no>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: nb\n"
"X-Poedit-SourceCharset: UTF-8\n"
msgid "Hello, Untranslated World!"
msgstr "Hallo, oversatte verden!"
nb
\ No newline at end of file
File added
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-03-01 14:40+0100\n"
"PO-Revision-Date: 2016-03-01 14:45+0100\n"
"Last-Translator: Hanne Moa <hanne.moa@uninett.no>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: nn\n"
"X-Poedit-SourceCharset: UTF-8\n"
msgid "Hello, Untranslated World!"
msgstr "Hallo, oversatte verd!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment