From 1b1beb989d278301a5b034d2c77151e08cdf9fb3 Mon Sep 17 00:00:00 2001 From: Hanne Moa <hanne.moa@uninett.no> Date: Tue, 1 Mar 2016 14:48:11 +0100 Subject: [PATCH] Start on new localization glue system --- lib/SimpleSAML/Locale/Localization.php | 78 +++++++++++++++++++++++++ locales/.gitkeep | 0 locales/en/LC_MESSAGES/ssp.mo | Bin 0 -> 495 bytes locales/en/LC_MESSAGES/ssp.po | 17 ++++++ locales/en_US | 1 + locales/nb/LC_MESSAGES/ssp.mo | Bin 0 -> 525 bytes locales/nb/LC_MESSAGES/ssp.po | 18 ++++++ locales/nb_NO | 1 + locales/nn/LC_MESSAGES/ssp.mo | Bin 0 -> 523 bytes locales/nn/LC_MESSAGES/ssp.po | 18 ++++++ 10 files changed, 133 insertions(+) create mode 100644 lib/SimpleSAML/Locale/Localization.php create mode 100644 locales/.gitkeep create mode 100644 locales/en/LC_MESSAGES/ssp.mo create mode 100644 locales/en/LC_MESSAGES/ssp.po create mode 120000 locales/en_US create mode 100644 locales/nb/LC_MESSAGES/ssp.mo create mode 100644 locales/nb/LC_MESSAGES/ssp.po create mode 120000 locales/nb_NO create mode 100644 locales/nn/LC_MESSAGES/ssp.mo create mode 100644 locales/nn/LC_MESSAGES/ssp.po diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php new file mode 100644 index 000000000..7fbef2b3a --- /dev/null +++ b/lib/SimpleSAML/Locale/Localization.php @@ -0,0 +1,78 @@ +<?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); + } + } +} + diff --git a/locales/.gitkeep b/locales/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/locales/en/LC_MESSAGES/ssp.mo b/locales/en/LC_MESSAGES/ssp.mo new file mode 100644 index 0000000000000000000000000000000000000000..c4931e30dedab05eaff5b91b41e4d67256cf716a GIT binary patch literal 495 zcmZvZ!A=4(5QbNympyti#=~&aNY^eBLl!Yc1R;UAnnk@<c7!!$y6G0958|tN^jVw* zgo~4Y=}h`hXWIGM+xha?wwXhw%Iq>1OldK5z}z$0mgi~S_nB|@c`dBWU0V;eHdPpr zvx*9>9H#JOtWGOlY|R^vo#?0H5p9tfiolQW64AD(9EakD<q_0mcrN6bkRgQis4h=r zC?yNU1HNZv+W)%RQa4bA6UnN$u@UqX5yH?YxR{o1Ff;0EP8p$d0hvpGplC8z6BG%m z8Mid-4?CL<!$A6NLk@|r{mi*Phac`V*D9kXjHk*L=vt$sD;gVJS^gER=+M}t8BHQ+ zykyRQ7Pm-fl`H#-4W^lcFlYpIK3Rt1S{0ZpH;o|hV?DP@i>|S=A_B@6VbQ8JVd=Jx X2r4ZIkDKc^M1bUbt0DaT!e#`&fGvp; literal 0 HcmV?d00001 diff --git a/locales/en/LC_MESSAGES/ssp.po b/locales/en/LC_MESSAGES/ssp.po new file mode 100644 index 000000000..70a64a7b7 --- /dev/null +++ b/locales/en/LC_MESSAGES/ssp.po @@ -0,0 +1,17 @@ +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!" diff --git a/locales/en_US b/locales/en_US new file mode 120000 index 000000000..2c4c454fd --- /dev/null +++ b/locales/en_US @@ -0,0 +1 @@ +en \ No newline at end of file diff --git a/locales/nb/LC_MESSAGES/ssp.mo b/locales/nb/LC_MESSAGES/ssp.mo new file mode 100644 index 0000000000000000000000000000000000000000..e0b0fd1ff49d8bfbe9fea4f2b3e9a4dfcbee76c6 GIT binary patch literal 525 zcmZvZOHRW;42A=OO_r<>V&U#UbV33JRVhV?@+cA&0m@@*8q)@)o@(MEH~}Z%dYpm- z;53MCu;$a)nt#Us$X_c<pPt5|vaZyXW#vFABT?3rYvp6X^K#u+m2b^;&7!>f7hTG8 zTZcOqhg{?+l){5`d0O)lXJ2R_<{~xs<ciF441RLeHyuYPTACA;$FLJd`zG8qVFXbl zZiHK56ox7^H}sm7*Z$Y-Rk}+o#PolgTNgtYnF)Fp;b2sz!Pw%_lrtugfbF4wi9DR* zkW8O&td@Egz0<kFC<y(IWg*sQ-zVx%=uNgKIcD5~!3bSJ(!T4TndV$qwtpsPPI+L{ zjE6BapEB_u%{ehSl+ssXDa{0;pcypuq$<rZ7BoQ_#Sr*OK6RLzGwa4h3_O{YMSG_O uRodQQsI?*5Z2kQ~Wl!_RZtc_!s8e~2p)%=paW*3RszX2#0!>oln)d^*>yw%Q literal 0 HcmV?d00001 diff --git a/locales/nb/LC_MESSAGES/ssp.po b/locales/nb/LC_MESSAGES/ssp.po new file mode 100644 index 000000000..f4e73b333 --- /dev/null +++ b/locales/nb/LC_MESSAGES/ssp.po @@ -0,0 +1,18 @@ +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!" diff --git a/locales/nb_NO b/locales/nb_NO new file mode 120000 index 000000000..6c2c32f1b --- /dev/null +++ b/locales/nb_NO @@ -0,0 +1 @@ +nb \ No newline at end of file diff --git a/locales/nn/LC_MESSAGES/ssp.mo b/locales/nn/LC_MESSAGES/ssp.mo new file mode 100644 index 0000000000000000000000000000000000000000..6e442efe212da853ebd67796b8a8a0ca19c78aa6 GIT binary patch literal 523 zcmZvZO-{o=421)NO_nTJAQol^f(Z!}RHYOlN}-jg2vB~urZH_$>Zv9!f)j88uE!}j z08WGG25UZzt$Ch#BY&+deR>*;%DS?nEGtJ!8Huu{Tq_?7o|o&ss(fp%YZhhiUvwzX z?GD_rIOHNnp%fmh%hL@narT7<V!ElhCs$;aWAKx!zG*o^(bAl$Jchk6IyB+F2_uMV zaV^{qqcBvVxuMsrZ2Mn#Q0XqQ5YzvC+`1S#$V||)2uGtb4aOEvrkpW}1Z<D}OXT4c zhh+MMW3|-l_S$oYQ4snq%R;QzzE9Mj(3|W|a?H2^gAuxdq<PmrH}$!$eEyl7Y4gCQ z84qKqKV{-SnhRobD5bB&Qkn@wK|QGHNmZItENFr<iXrfmeCjYa=hlsj7<e)(i{@Sf ss<gSuu+fBQtMT^-mGS(tTRU|FYE>R%s7!htoQ=r7>JU(bKocF$4~C?Y(EtDd literal 0 HcmV?d00001 diff --git a/locales/nn/LC_MESSAGES/ssp.po b/locales/nn/LC_MESSAGES/ssp.po new file mode 100644 index 000000000..0ce9baabb --- /dev/null +++ b/locales/nn/LC_MESSAGES/ssp.po @@ -0,0 +1,18 @@ +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!" -- GitLab