$app->add(function ($request, $response, $next) use ($i18n) {
$get = $request->getQueryParams();
- if (isset($get['pref_lang'])) {
+ if (isset($get['ui_pref_lang'])) {
$route = $request->getAttribute('route');
$route_name = $route->getName();
$arguments = $route->getArguments();
- $this->i18n->changeLanguage($get['pref_lang']);
+ $this->i18n->changeLanguage($get['ui_pref_lang']);
$this->session->i18n = $this->i18n;
return $response->withRedirect(
'page_title' => _T("Member Profile"),
'require_dialog' => true,
'member' => $member,
- 'pref_lang_img' => $this->i18n->getFlagFromId($member->language),
'pref_lang' => ucfirst($this->i18n->getNameFromId($member->language)),
'pref_card_self' => $this->preferences->pref_card_self,
'groups' => Groups::getSimpleList(),
'page_title' => _T("Member Profile"),
'require_dialog' => true,
'member' => $member,
- 'pref_lang_img' => $this->i18n->getFlagFromId($member->language),
'pref_lang' => ucfirst($this->i18n->getNameFromId($member->language)),
'pref_card_self' => $this->preferences->pref_card_self,
'groups' => Groups::getSimpleList(),
private $longid;
private $name;
private $abbrev;
- private $flag;
const DEFAULT_LANG = 'fr_FR';
$this->longid = $lang['long'];
$this->name = $lang['longname'];
$this->abbrev = $lang['shortname'];
- $this->flag = $lang['flag'];
}
/**
}
}
- /**
- * Gets the language flag from its ID
- *
- * @param string $id the language identifier
- *
- * @return string path to flag for specified language identifier
- */
- public function getFlagFromId($id)
- {
- $path = null;
- if (!isset($this->langs[$id])) {
- Analog::log(
- str_replace(
- '%lang',
- $id,
- _T('Unknown lang (%lang)')
- ),
- Analog::INFO
- );
- } else {
- if (defined('GALETTE_THEME_DIR')) {
- $path = GALETTE_THEME_DIR . 'images/flags/' . $this->langs['id']['flag'];
- } else {
- $path = GALETTE_THEME . 'images/flags/' . $this->langs[$id]['flag'];
- }
- }
- return $path;
- }
-
/**
* Get current id
*
return $this->abbrev;
}
- /**
- * Get current flag
- *
- * @return string path to the current language flag image
- */
- public function getFlag()
- {
- if (defined('GALETTE_THEME_DIR')) {
- return GALETTE_THEME_DIR . 'images/flags/' . $this->flag;
- } else {
- return GALETTE_THEME . 'images/flags/' . $this->flag;
- }
- }
-
/**
* Is a string seem to be UTF-8 one ?
*
public function guessLangs()
{
$dir = new \DirectoryIterator($this->path);
- $flags_dir = GALETTE_ROOT . 'webroot/themes/default/images/flags/';
$langs = [];
foreach ($dir as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
$lang = $fileinfo->getFilename();
$real_lang = str_replace('.utf8', '', $lang);
$parsed_lang = \Locale::parseLocale($lang);
- $flag = (file_exists($flags_dir . $real_lang . '.svg') ?
- $real_lang . '.svg' :
- 'default.svg');
$langs[$real_lang] = [
'long' => $lang,
'longname' => \Locale::getDisplayLanguage(
$lang,
$lang
- ),
- 'flag' => $flag
+ )
];
}
}
{block name="element"}
<select name="pref_lang" id="pref_lang" class="lang"{if isset($disabled) and $disabled == true} disabled="disabled"{/if}{if isset($required.pref_lang) and $required.pref_lang eq 1} required="required"{/if}>
{foreach item=langue from=$languages}
- <option value="{$langue->getID()}"{if $member->language eq $langue->getID()} selected="selected"{/if} style="background-image:url({base_url}/{$langue->getFlag()});">{$langue->getName()|ucfirst}</option>
+ <option value="{$langue->getID()}"{if $member->language eq $langue->getID()} selected="selected"{/if}>{$langue->getName()|ucfirst}</option>
{/foreach}
</select>
{/block}
<label for="sel_lang">{_T string="Language:"}</label>
<select name="sel_lang" id="sel_lang" class="lang">
{foreach item=langue from=$langlist}
- <option value="{$langue->getID()}" {if $cur_lang eq $langue->getID()}selected="selected"{/if} style="background-image: url({base_url|cat:'/'|cat:$langue->getFlag()});">{$langue->getName()}</option>
+ <option value="{$langue->getID()}" {if $cur_lang eq $langue->getID()}selected="selected"{/if}>{$langue->getName()|ucfirst}</option>
{/foreach}
</select>
{* Include plugins menu entries *}
{$plugins->getMenus($tpl)}
- <ul id="langs">
+ <form action="">
+ <select id="lang_selector" name="ui_pref_lang">
{foreach item=langue from=$languages}
- <li>
- <a href="?pref_lang={$langue->getID()}" title="{_T string="Switch locale to '%locale'" pattern="/%locale/" replace=$langue->getName()}" class="flag">
- <img src="{base_url}/{$langue->getFlag()}" alt="{$langue->getName()}" lang="{$langue->getAbbrev()}"/>
- </a>
- </li>
+ <option value="{$langue->getID()}" lang="{$langue->getAbbrev()}"{if $galette_lang eq $langue->getAbbrev()} selected="selected"{/if}>{$langue->getName()|ucfirst}</option>
{/foreach}
- </ul>
+ </select>
+ <noscript>
+ <input type="submit" name="{_T string="Change language"}" />
+ </noscript>
+ </form>
{if $login->isLogged()}
<div>{$login->loggedInAs()}</div>
<a id="logout_10" class="button" href="{if $login->isImpersonated()}{path_for name="unimpersonate"}{else}{path_for name="logout"}{/if}"><i class="fas fa-{if $login->isImpersonated()}user-secret{else}sign-out-alt{/if}"></i>{_T string="Log off"}</a>
<label for="pref_lang" class="bline">{_T string="Default language:"}</label>
<select name="pref_lang" id="pref_lang" class="lang">
{foreach item=langue from=$languages}
- <option value="{$langue->getID()}" {if $pref.pref_lang eq $langue->getID()}selected="selected"{/if} style="background-image: url({base_url}/{$langue->getFlag()});">{$langue->getName()|ucfirst}</option>
+ <option value="{$langue->getID()}" {if $pref.pref_lang eq $langue->getID()}selected="selected"{/if}>{$langue->getName()|ucfirst}</option>
{/foreach}
</select>
</p>
<![endif]-->
<header>
<img src="{path_for name="logo"}" width="{$logo->getOptimalWidth()}" height="{$logo->getOptimalHeight()}" alt="[ Galette ]" />
- <ul id="langs">
+ <form action="" id="plang_selector">
+ <select id="lang_selector" name="ui_pref_lang">
{foreach item=langue from=$languages}
- <li>
- <a href="?pref_lang={$langue->getID()}" title="{_T string="Switch locale to '%locale'" pattern="/%locale/" replace=$langue->getName()}" class="flag">
- <img src="{base_url}/{$langue->getFlag()}" alt="{$langue->getName()}" lang="{$langue->getAbbrev()}"/>
- </a>
- </li>
+ <option value="{$langue->getID()}" lang="{$langue->getAbbrev()}"{if $galette_lang eq $langue->getAbbrev()} selected="selected"{/if}>{$langue->getName()|ucfirst}</option>
{/foreach}
- </ul>
+ </select>
+ <noscript>
+ <input type="submit" name="{_T string="Change language"}" />
+ </noscript>
+ </form>
{if $login->isLogged()}
<div id="user">
<a id="userlink" class="tooltip" title="{_T string="View your member card"}" href="{if $login->isSuperAdmin()}{path_for name="slash"}{else}{path_for name="me"}{/if}">{$login->loggedInAs(true)}</a>
{elseif $member->isWoman()}
<i class="fas fa-venus fa-fw"></i>
{/if}
- {elseif $element->field_id eq 'pref_lang'}
- <img src="{base_url}/{$pref_lang_img}" alt="" class="flag"/>
{/if}
{if $element->field_id eq 'email_adh' or $element->field_id eq 'msn_adh'}
<a href="mailto:{$value}">{$value}</a>
<h1 id="titre">
<?php echo _T("Galette installation") . ' - ' . $install->getStepTitle(); ?>
</h1>
- <ul id="langs">
+
+ <form action="">
+ <select id="lang_selector" name="ui_pref_lang">
<?php
foreach ($i18n->getList() as $langue) {
?>
- <li><a href="?pref_lang=<?php echo $langue->getID(); ?>"><img src="<?php echo $langue->getFlag(); ?>" alt="<?php echo $langue->getName(); ?>" lang="<?php echo $langue->getAbbrev(); ?>" class="flag"/></a></li>
+ <option value="<?php echo $langue->getID(); ?>" lang="<?php echo $langue->getAbbrev(); ?>"<?php if ($galette_lang == $langue->getAbbrev()) { echo ' selected="selected"'; } ?>>{<?php echo $langue->getName(); ?></option>
<?php
}
?>
- </ul>
+ </select>
+ <noscript>
+ <input type="submit" name="{_T string="Change language"}" />
+ </noscript>
+ </form>
</header>
<?php
if (count($error_detected) > 0) {
}
});
}
+
+ $('#lang_selector').change(function() {
+ this.form.submit();
+ });
});
#menu li.selected a{
background-color: #DDDDFF;
}
-
-#langs{
- list-style-type:none;
- margin:1em 1em 0;
- padding:0;
- display:inline-block;
-}
-#langs li{
- padding:0;
- margin:0;
- display:inline;
- background-color:transparent;
-}
-#langs li a{
- display:inline;
-}
/* =/ Main menu */
/*
min-width: 25em;
}
-#galette_body .selectize-input {
+#galette_body .selectize-input, .public_page .selectize-input {
padding: .1em 20px .1em 8px;
overflow: unset;
}
-#galette_body .selectize-dropdown .option {
+#galette_body .selectize-dropdown .option, .public_page .selectize-dropdown .option {
cursor: pointer;
}
-#galette_body .selectize-dropdown .active {
+#galette_body .selectize-dropdown .active, .public_page .selectize-dropdown .active {
background-color: #DDDDFF;
}
-#galette_body .selectize-dropdown .option, #galette_body .selectize-dropdown .optgroup-header {
+#galette_body .selectize-dropdown .option, #galette_body .selectize-dropdown .optgroup-header,
+.public_page .selectize-dropdown .option, .public_page .selectize-dropdown .optgroup-header {
padding: .2em .5em;
}
.public_page p {
margin: 1em auto .5em;
}
-.public_page #langs {
- display: block;
- margin:.2em 0;
-}
.public_page section {
text-align: center;
.public_page #user {
position: absolute;
- top:0;
+ top:3em;
right:0;
display:inline-block;
- border-bottom:1px solid #DDDDFF;
- border-left:1px solid #DDDDFF;
- -moz-border-bottom-left-radius: 10px;
- -webkit-border-bottom-left-radius: 10px;
- border-bottom-left-radius: 10px;
}
.public_page #userlink {
margin: 0 .5em .2em;
}
+.public_page #plang_selector {
+ position: absolute;
+ right: .5em;
+ top: .5em;
+}
+
/* =/ Public pages */
/*
text-align: center;
}
-#langs li a.flag:hover {
- text-decoration: none;
-}
-
-.flag img, img.flag
-{
- width: 22px;
- height: 16px;
-}
-
.bigtable
{
text-align: center;
padding: .1em 1em;
}
-.galette_form #pref_lang option {
- background-size: 16px;
- background-repeat: no-repeat;
- padding-left: 20px;
- background-position: 0 50%;
-}
-
.galette_form img.mdp_img {
vertical-align: top;
}
/** Mobile devices */
@media (max-width: 767px) {
- body:before {
- content: "- Galette Version mobile -";
- display: block;
- color: #777;
- text-align: center;
- font-style: italic;
- padding-top: .2em;
- }
-
/* passer tous les éléments de largeur fixe en largeur automatique */
body {
width: auto !important;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="600" viewBox="0 0 5 3">
- <desc>Flag of Germany</desc>
- <rect id="black_stripe" width="5" height="3" y="0" x="0" fill="#000"/>
- <rect id="red_stripe" width="5" height="2" y="1" x="0" fill="#D00"/>
- <rect id="gold_stripe" width="5" height="1" y="2" x="0" fill="#FFCE00"/>
-</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Creator: CorelDRAW -->
-<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="600px" height="400px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
-viewBox="0 0 600 400">
- <defs>
- <style type="text/css">
- <![CDATA[
- .str0 {stroke:black;stroke-width:0.1524}
- .fil0 {fill:#72706F}
- .fil2 {fill:#969594}
- .fil1 {fill:#C2C1C1}
- .fil3 {fill:white;fill-rule:nonzero}
- ]]>
- </style>
- </defs>
- <g id="Layer_x0020_1">
- <metadata id="CorelCorpID_0Corel-Layer"/>
- <g id="_133046256">
- <polygon id="_20430272" class="fil0" points="0,0 200,0 200,400 0,400 "/>
- <polygon id="_20643720" class="fil1" points="200,0 400,0 400,400 200,400 "/>
- <polygon id="_20431056" class="fil2" points="400,0 600,0 600,400 400,400 "/>
- <path id="_20549048" class="fil3 str0" d="M348.367 270.386l-93.7054 0 0 -9.3454c0,-15.9122 1.768,-28.8778 5.3882,-38.8124 3.6202,-10.0188 9.0086,-19.0274 16.1648,-27.2782 7.1564,-8.2508 23.237,-22.7318 48.242,-43.443 13.3024,-10.8608 19.9534,-20.7954 19.9534,-29.8038 0,-9.0928 -2.694,-16.0808 -7.9982,-21.1322 -5.3882,-4.9674 -13.4706,-7.4932 -24.3314,-7.4932 -11.7026,0 -21.3006,3.873 -28.962,11.6186 -7.6614,7.6614 -12.5446,21.2164 -14.6494,40.412l-95.7262 -11.871c3.2836,-35.1922 16.0808,-63.4806 38.3074,-84.9496 22.3108,-21.469 56.4928,-32.1612 102.546,-32.1612 35.8658,0 64.7436,7.493 86.8018,22.395 29.8882,20.2902 44.8744,47.2316 44.8744,80.9084 0,13.9758 -3.8728,27.5306 -11.6186,40.4962 -7.6614,12.9656 -23.4894,28.8778 -47.3158,47.5684 -16.5858,13.2182 -27.1098,23.7422 -31.4878,31.7404 -4.2938,7.914 -6.4828,18.3538 -6.4828,31.151zm-96.989 24.9208l100.441 0 0 88.5698 -100.441 0 0 -88.5698z"/>
- </g>
- </g>
-</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1235" height="650" viewBox="0 0 7410 3900">
-<rect width="7410" height="3900" fill="#b22234"/>
-<path d="M0,450H7410m0,600H0m0,600H7410m0,600H0m0,600H7410m0,600H0" stroke="#fff" stroke-width="300"/>
-<rect width="2964" height="2100" fill="#3c3b6e"/>
-<g fill="#fff">
-<g id="s18">
-<g id="s9">
-<g id="s5">
-<g id="s4">
-<path id="s" d="M247,90 317.534230,307.082039 132.873218,172.917961H361.126782L176.465770,307.082039z"/>
-<use xlink:href="#s" y="420"/>
-<use xlink:href="#s" y="840"/>
-<use xlink:href="#s" y="1260"/>
-</g>
-<use xlink:href="#s" y="1680"/>
-</g>
-<use xlink:href="#s4" x="247" y="210"/>
-</g>
-<use xlink:href="#s9" x="494"/>
-</g>
-<use xlink:href="#s18" x="988"/>
-<use xlink:href="#s9" x="1976"/>
-<use xlink:href="#s5" x="2470"/>
-</g>
-</svg>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="#ED2939"/><rect width="600" height="600" fill="#fff"/><rect width="300" height="600" fill="#002395"/></svg>
$list = $this->i18n->getList();
$this->array($list)
- ->hasSize(3);
+ ->size->isGreaterThan(3);
foreach ($list as $elt) {
$this->object($elt)
{
$list = $this->i18n->getArrayList();
- $expected = [
- 'de_DE' => 'Deutsch',
- 'en_US' => 'English',
- 'fr_FR' => 'Français'
- ];
-
$this->array($list)
- ->isIdenticalTo($expected);
+ ->size->isGreaterThan(3);
}
/**
->isIdenticalTo('English');
}
- /**
- * Test getting flag from its ID
- *
- * @return void
- */
- public function testGetFlagFromid()
- {
- $flag = $this->i18n->getFlagFromId('en_US');
-
- $this->variable($flag)
- ->isIdenticalTo(
- GALETTE_THEME. 'images/flags/en_US.svg'
- );
- }
-
/**
* Test retrieving language informations
*
$longid = $this->i18n->getLongID();
$name = $this->i18n->getName();
$abbrev = $this->i18n->getAbbrev();
- $flag = $this->i18n->getFlag();
$this->variable($id)
->isIdenticalTo('fr_FR');
->isIdenticalTo('français');
$this->variable($abbrev)
->isIdenticalTo('fr');
- $this->variable($flag)
- ->isIdenticalTo(
- GALETTE_THEME . 'images/flags/fr_FR.svg'
- );
}
/**