summaryrefslogtreecommitdiff
path: root/includes/helper/internationalization_helper.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-28 22:23:59 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-29 23:46:31 +0200
commit427315195bdd379a0207fc9b2aaf69a5b5b86c79 (patch)
tree678245351333a16c5a5bca129aada4bfd311c23c /includes/helper/internationalization_helper.php
parentdf6360044b5c2396b2bee0dfa9e8d744bfa424d5 (diff)
Moved translation/internationalization to Helpers\Translator class
Diffstat (limited to 'includes/helper/internationalization_helper.php')
-rw-r--r--includes/helper/internationalization_helper.php80
1 files changed, 0 insertions, 80 deletions
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
deleted file mode 100644
index bb6d0abd..00000000
--- a/includes/helper/internationalization_helper.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-/**
- * Return currently active locale
- *
- * @return string
- */
-function locale()
-{
- return session()->get('locale');
-}
-
-/**
- * Returns two letter language code from currently active locale
- *
- * @return string
- */
-function locale_short()
-{
- return substr(locale(), 0, 2);
-}
-
-/**
- * Initializes gettext for internationalization and updates the sessions locale to use for translation.
- */
-function gettext_init()
-{
- $locales = config('locales');
- $request = request();
- $session = session();
-
- if ($request->has('set_locale') && isset($locales[$request->input('set_locale')])) {
- $session->set('locale', $request->input('set_locale'));
- } elseif (!$session->has('locale')) {
- $session->set('locale', config('default_locale'));
- }
-
- gettext_locale();
- bindtextdomain('default', app('path.lang'));
- bind_textdomain_codeset('default', 'UTF-8');
- textdomain('default');
-}
-
-/**
- * Swich gettext locale.
- *
- * @param string $locale
- */
-function gettext_locale($locale = null)
-{
- if (empty($locale)) {
- $locale = session()->get('locale');
- }
-
- putenv('LC_ALL=' . $locale);
- setlocale(LC_ALL, $locale);
-}
-
-/**
- * Renders language selection.
- *
- * @return array
- */
-function make_langselect()
-{
- $request = app('request');
-
- $items = [];
- foreach (config('locales') as $locale => $name) {
- $url = url($request->getPathInfo(), ['set_locale' => $locale]);
-
- $items[] = toolbar_item_link(
- htmlspecialchars($url),
- '',
- $name,
- $locale == locale()
- );
- }
- return $items;
-}