Utilisation des json de messages pour les boutons de langue
This commit is contained in:
parent
accaf328c2
commit
115b432771
File diff suppressed because one or more lines are too long
@ -1,80 +1,86 @@
|
|||||||
import React, {Component} from '../../../node_modules/react';
|
import './MenuComponent.scss';
|
||||||
import {FormattedMessage} from 'react-intl';
|
|
||||||
import './MenuComponent.scss'
|
|
||||||
|
|
||||||
const URL_add_parameter = function(url, param, value){
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
||||||
var hash = {};
|
|
||||||
var parser = document.createElement('a');
|
|
||||||
|
|
||||||
parser.href = url;
|
import React, { Component } from '../../../node_modules/react';
|
||||||
|
|
||||||
|
|
||||||
|
const URL_add_parameter = function (url, param, value) {
|
||||||
|
var hash = {};
|
||||||
|
var parser = document.createElement('a');
|
||||||
|
|
||||||
|
parser.href = url;
|
||||||
|
|
||||||
var parameters = parser.search.split(/\?|&/);
|
var parameters = parser.search.split(/\?|&/);
|
||||||
|
|
||||||
for(var i=0; i < parameters.length; i++) {
|
for (var i = 0; i < parameters.length; i++) {
|
||||||
if(!parameters[i])
|
if (!parameters[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var ary = parameters[i].split('=');
|
var ary = parameters[i].split('=');
|
||||||
hash[ary[0]] = ary[1];
|
hash[ary[0]] = ary[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
hash[param] = value;
|
hash[param] = value;
|
||||||
|
|
||||||
var list = [];
|
var list = [];
|
||||||
Object.keys(hash).forEach(function (key) {
|
Object.keys(hash).forEach(function (key) {
|
||||||
list.push(key + '=' + hash[key]);
|
list.push(key + '=' + hash[key]);
|
||||||
});
|
});
|
||||||
|
|
||||||
parser.search = '?' + list.join('&');
|
parser.search = '?' + list.join('&');
|
||||||
return parser.href;
|
return parser.href;
|
||||||
}
|
}
|
||||||
export default class MenuComponent extends Component {
|
class MenuComponent extends Component {
|
||||||
// constructor(props) {
|
// constructor(props) {
|
||||||
// super(props);
|
// super(props);
|
||||||
// this.state = {};
|
// this.state = {};
|
||||||
// }
|
// }
|
||||||
honhonhon() {
|
honhonhon() {
|
||||||
window.location.href=URL_add_parameter(window.location.href, "lang", "fr");
|
window.location.href = URL_add_parameter(window.location.href, "lang", "fr");
|
||||||
}
|
}
|
||||||
|
|
||||||
heygovna() {
|
heygovna() {
|
||||||
window.location.href=URL_add_parameter(window.location.href, "lang", "en");
|
window.location.href = URL_add_parameter(window.location.href, "lang", "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <section id="menu" class="hero is-primary dontPrint is-bold">
|
const buttonsLanguagesMessage = this.props.intl.messages.global.buttons.languages;
|
||||||
<div class="hero-body">
|
return <section id="menu" class="hero is-primary dontPrint is-bold">
|
||||||
<div class="container">
|
<div class="hero-body">
|
||||||
<div class="columns">
|
<div class="container">
|
||||||
<div class="column">
|
<div class="columns">
|
||||||
<h1 class="title">
|
<div class="column">
|
||||||
<FormattedMessage id="title"/>
|
<h1 class="title">
|
||||||
</h1>
|
<FormattedMessage id="title" />
|
||||||
<h2 class="subtitle">
|
</h1>
|
||||||
<FormattedMessage id="subtitle"/>
|
<h2 class="subtitle">
|
||||||
</h2>
|
<FormattedMessage id="subtitle" />
|
||||||
</div>
|
</h2>
|
||||||
<div class="column is-hidden-touch">
|
</div>
|
||||||
<div id="langButtons">
|
<div class="column is-hidden-touch">
|
||||||
<div class="buttons">
|
<div id="langButtons">
|
||||||
<span class="button is-light" onClick={this.honhonhon}>
|
<div class="buttons">
|
||||||
En Français 🇫🇷
|
<span class="button is-light" onClick={this.honhonhon}>
|
||||||
</span>
|
{buttonsLanguagesMessage.fr}
|
||||||
<span class="button is-light" onClick={this.heygovna}>
|
</span>
|
||||||
In English 🇮🇪
|
<span class="button is-light" onClick={this.heygovna}>
|
||||||
</span>
|
{buttonsLanguagesMessage.en}
|
||||||
</div>
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</section>;
|
</section>;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// export default connect(
|
// export default connect(
|
||||||
// ({ MenuComponent }) => ({ ...MenuComponent }),
|
// ({ MenuComponent }) => ({ ...MenuComponent }),
|
||||||
// dispatch => bindActionCreators({ ...MenuComponentActions }, dispatch)
|
// dispatch => bindActionCreators({ ...MenuComponentActions }, dispatch)
|
||||||
// )( MenuComponent );
|
// )( MenuComponent );
|
||||||
|
|
||||||
|
export default injectIntl(MenuComponent)
|
Loading…
x
Reference in New Issue
Block a user