diff --git a/composer.json b/composer.json
index 71e97b073b319fb04195efbeb5e76ed650ef84fa..b51881835a3d779dc6e7379d12679ce8460e1924 100644
--- a/composer.json
+++ b/composer.json
@@ -49,7 +49,8 @@
         "ext-pcre": "*",
         "ext-SPL": "*",
         "ext-zlib": "*",
-        "gettext/gettext": "4.x-dev#3e7460f8d9c90174824e3f39240bd578bb3d376a",
+        "gettext/gettext": "^5.6.1",
+        "gettext/translator": "^1.0.1",
         "phpmailer/phpmailer": "^6.5",
         "simplesamlphp/assert": "^0.2.11",
         "simplesamlphp/saml2": "^4.5",
diff --git a/composer.lock b/composer.lock
index 72ed91148b8275c93486fa6b0d42ad56c13bb628..f2ea7b063ee89a97022ea9e874fc3c917e0ff21f 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,39 +4,32 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "b961c9acd0500cbabf669f97bea560ae",
+    "content-hash": "46c45be4da6d65074a1e47b53252dcba",
     "packages": [
         {
             "name": "gettext/gettext",
-            "version": "4.x-dev",
+            "version": "v5.6.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/php-gettext/Gettext.git",
-                "reference": "3e7460f8d9c90174824e3f39240bd578bb3d376a"
+                "reference": "017e249601d32b9a88c2eb4c10eac89bf582a7d3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-gettext/Gettext/zipball/3e7460f8d9c90174824e3f39240bd578bb3d376a",
-                "reference": "3e7460f8d9c90174824e3f39240bd578bb3d376a",
+                "url": "https://api.github.com/repos/php-gettext/Gettext/zipball/017e249601d32b9a88c2eb4c10eac89bf582a7d3",
+                "reference": "017e249601d32b9a88c2eb4c10eac89bf582a7d3",
                 "shasum": ""
             },
             "require": {
                 "gettext/languages": "^2.3",
-                "php": ">=5.4.0"
+                "php": "^7.2|^8.0"
             },
             "require-dev": {
-                "illuminate/view": "^5.0.x-dev",
-                "phpunit/phpunit": "^4.8|^5.7|^6.5",
-                "squizlabs/php_codesniffer": "^3.0",
-                "symfony/yaml": "~2",
-                "twig/extensions": "*",
-                "twig/twig": "^1.31|^2.0"
-            },
-            "suggest": {
-                "illuminate/view": "Is necessary if you want to use the Blade extractor",
-                "symfony/yaml": "Is necessary if you want to use the Yaml extractor/generator",
-                "twig/extensions": "Is necessary if you want to use the Twig extractor",
-                "twig/twig": "Is necessary if you want to use the Twig extractor"
+                "brick/varexporter": "^0.3.5",
+                "friendsofphp/php-cs-fixer": "^3.2",
+                "oscarotero/php-cs-fixer-config": "^2.0",
+                "phpunit/phpunit": "^8.0|^9.0",
+                "squizlabs/php_codesniffer": "^3.0"
             },
             "type": "library",
             "autoload": {
@@ -57,7 +50,7 @@
                 }
             ],
             "description": "PHP gettext manager",
-            "homepage": "https://github.com/oscarotero/Gettext",
+            "homepage": "https://github.com/php-gettext/Gettext",
             "keywords": [
                 "JS",
                 "gettext",
@@ -68,8 +61,8 @@
             ],
             "support": {
                 "email": "oom@oscarotero.com",
-                "issues": "https://github.com/oscarotero/Gettext/issues",
-                "source": "https://github.com/php-gettext/Gettext/tree/4.x"
+                "issues": "https://github.com/php-gettext/Gettext/issues",
+                "source": "https://github.com/php-gettext/Gettext/tree/v5.6.1"
             },
             "funding": [
                 {
@@ -85,7 +78,7 @@
                     "type": "patreon"
                 }
             ],
-            "time": "2022-02-17T10:14:02+00:00"
+            "time": "2021-12-04T11:33:21+00:00"
         },
         {
             "name": "gettext/languages",
@@ -161,6 +154,80 @@
             ],
             "time": "2021-11-11T17:30:39+00:00"
         },
+        {
+            "name": "gettext/translator",
+            "version": "v1.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-gettext/Translator.git",
+                "reference": "b18ff33e8203de623854561f5e47e992fc5c50bb"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-gettext/Translator/zipball/b18ff33e8203de623854561f5e47e992fc5c50bb",
+                "reference": "b18ff33e8203de623854561f5e47e992fc5c50bb",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2|^8.0"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^2.15",
+                "gettext/gettext": "^5.0.0",
+                "oscarotero/php-cs-fixer-config": "^1.0",
+                "phpunit/phpunit": "^8.0",
+                "squizlabs/php_codesniffer": "^3.0"
+            },
+            "suggest": {
+                "gettext/gettext": "Is necessary to load and generate array files used by the translator"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Gettext\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Oscar Otero",
+                    "email": "oom@oscarotero.com",
+                    "homepage": "http://oscarotero.com",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Gettext translator functions",
+            "homepage": "https://github.com/php-gettext/Translator",
+            "keywords": [
+                "gettext",
+                "i18n",
+                "php",
+                "translator"
+            ],
+            "support": {
+                "email": "oom@oscarotero.com",
+                "issues": "https://github.com/php-gettext/Translator/issues",
+                "source": "https://github.com/php-gettext/Translator/tree/v1.1.1"
+            },
+            "funding": [
+                {
+                    "url": "https://paypal.me/oscarotero",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/oscarotero",
+                    "type": "github"
+                },
+                {
+                    "url": "https://www.patreon.com/misteroom",
+                    "type": "patreon"
+                }
+            ],
+            "time": "2022-02-23T20:29:40+00:00"
+        },
         {
             "name": "phpmailer/phpmailer",
             "version": "v6.6.0",
@@ -6056,16 +6123,16 @@
         },
         {
             "name": "simplesamlphp/simplesamlphp-module-adfs",
-            "version": "v2.0.0-rc7",
+            "version": "v2.0.0-rc8",
             "source": {
                 "type": "git",
                 "url": "https://github.com/simplesamlphp/simplesamlphp-module-adfs.git",
-                "reference": "1896711da0a9a1974ac760afc3ddbb6589498b4d"
+                "reference": "ccb86deb3dcb4d9c99483b479534beb22144ad31"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-module-adfs/zipball/1896711da0a9a1974ac760afc3ddbb6589498b4d",
-                "reference": "1896711da0a9a1974ac760afc3ddbb6589498b4d",
+                "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-module-adfs/zipball/ccb86deb3dcb4d9c99483b479534beb22144ad31",
+                "reference": "ccb86deb3dcb4d9c99483b479534beb22144ad31",
                 "shasum": ""
             },
             "require": {
@@ -6103,7 +6170,7 @@
                 "issues": "https://github.com/simplesamlphp/simplesamlphp-module-adfs/issues",
                 "source": "https://github.com/simplesamlphp/simplesamlphp-module-adfs"
             },
-            "time": "2022-02-19T15:45:36+00:00"
+            "time": "2022-03-16T16:39:11+00:00"
         },
         {
             "name": "simplesamlphp/simplesamlphp-test-framework",
@@ -6632,7 +6699,6 @@
     "aliases": [],
     "minimum-stability": "stable",
     "stability-flags": {
-        "gettext/gettext": 20,
         "simplesamlphp/simplesamlphp-module-adfs": 5
     },
     "prefer-stable": false,
diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php
index 0f446864fd4819e9af8e9436aa57130d60f92ea4..5dc2a064bd5f973ed77b34388ae269b10ea434fa 100644
--- a/lib/SimpleSAML/Locale/Localization.php
+++ b/lib/SimpleSAML/Locale/Localization.php
@@ -11,8 +11,11 @@ declare(strict_types=1);
 namespace SimpleSAML\Locale;
 
 use Exception;
+use Gettext\Generator\ArrayGenerator;
+use Gettext\Loader\PoLoader;
 use Gettext\Translations;
 use Gettext\Translator;
+use Gettext\TranslatorFunctions;
 use SimpleSAML\Configuration;
 use SimpleSAML\Logger;
 use Symfony\Component\Filesystem\Filesystem;
@@ -93,6 +96,15 @@ class Localization
     }
 
 
+    /**
+     * @return \GetText\Translator
+     */
+    public function getTranslator(): Translator
+    {
+        return $this->translator;
+    }
+
+
     /**
      * Dump the default locale directory
      *
@@ -205,7 +217,7 @@ class Localization
     private function setupTranslator(): void
     {
         $this->translator = new Translator();
-        $this->translator->register();
+        TranslatorFunctions::register($this->translator);
     }
 
 
@@ -239,8 +251,11 @@ class Localization
 
         $file = new File($langPath . $domain . '.po');
         if ($this->fileSystem->exists($file->getRealPath()) && $file->isReadable()) {
-            $translations = Translations::fromPoFile($file->getRealPath());
-            $this->translator->loadTranslations($translations);
+            $translations = (new PoLoader())->loadFile($file->getRealPath());
+            $arrayGenerator = new ArrayGenerator();
+            $this->translator->addTranslations(
+                $arrayGenerator->generateArray($translations)
+            );
         } else {
             Logger::debug(sprintf(
                 "%s - Localization file '%s' not found or not readable in '%s', falling back to default",
diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php
index f8468dd03bc8d3da9163c872391019301226db99..dbfd793ab8c81d83f2b3d62f86c41c7acb0f15f2 100644
--- a/lib/SimpleSAML/Locale/Translate.php
+++ b/lib/SimpleSAML/Locale/Translate.php
@@ -10,7 +10,8 @@ declare(strict_types=1);
 
 namespace SimpleSAML\Locale;
 
-use Gettext\BaseTranslator;
+use Gettext\Translator;
+use Gettext\TranslatorFunctions;
 use SimpleSAML\Assert\Assert;
 use SimpleSAML\Configuration;
 use SimpleSAML\Logger;
@@ -81,7 +82,7 @@ class Translate
         // This may happen if you forget to set a variable and then run undefinedVar through the trans-filter
         $original = $original ?? 'undefined variable';
 
-        $text = BaseTranslator::$current->gettext($original);
+        $text = TranslatorFunctions::getTranslator()->gettext($original);
 
         if (func_num_args() === 1) {
             return $text;
@@ -98,16 +99,16 @@ class Translate
      *
      * @param string|null $original The string before translation.
      * @param string $plural
-     * @param string $value
+     * @param int $value
      *
      * @return string The translated string.
      */
-    public static function translatePluralGettext(?string $original, string $plural, string $value): string
+    public static function translatePluralGettext(?string $original, string $plural, int $value): string
     {
         // This may happen if you forget to set a variable and then run undefinedVar through the trans-filter
         $original = $original ?? 'undefined variable';
 
-        $text = BaseTranslator::$current->ngettext($original, $plural, $value);
+        $text = TranslatorFunctions::getTranslator()->ngettext($original, $plural, $value);
 
         if (func_num_args() === 3) {
             return $text;