1
0
mirror of https://github.com/flarum/core.git synced 2025-07-30 21:20:24 +02:00

Add option to hide the language selector (#1106)

* Added option to hide the language selector in the header
* Added `hide_language_selector` Switch to BasicsPage
* Added `hideLanguageSelector` property to ForumSerializer
* Apparently fixed the "Add Extension" button locale.... someone must not have compiled their changes :P

* Changed hideLanguageSelector (and such) to showLanguageSelector

* Change `core.admin.basics.show_language_selector_heading` to be `_label`

* Change showLanguageSelector in ForumSerializer to be boolean, default: true

* Ooops! Remove console.log 🤦‍♂️
This commit is contained in:
David Sevilla Martín
2017-03-06 18:34:45 -05:00
committed by Toby Zerner
parent 7862bd32dd
commit 60d3d6ef99
5 changed files with 42 additions and 19 deletions

View File

@@ -23215,7 +23215,7 @@ System.register('flarum/components/HeaderSecondary', ['flarum/Component', 'flaru
items.add('search', app.search.render(), 30);
if (Object.keys(app.data.locales).length > 1) {
if (app.forum.attribute("showLanguageSelector") && Object.keys(app.data.locales).length > 1) {
var locales = [];
var _loop = function _loop(locale) {

View File

@@ -39,28 +39,28 @@ export default class HeaderSecondary extends Component {
items.add('search', app.search.render(), 30);
if (Object.keys(app.data.locales).length > 1) {
if (app.forum.attribute("showLanguageSelector") && Object.keys(app.data.locales).length > 1) {
const locales = [];
for (const locale in app.data.locales) {
locales.push(Button.component({
active: app.data.locale === locale,
children: app.data.locales[locale],
icon: app.data.locale === locale ? 'check' : true,
onclick: () => {
if (app.session.user) {
app.session.user.savePreferences({locale}).then(() => window.location.reload());
} else {
document.cookie = `locale=${locale}; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT`;
window.location.reload();
active: app.data.locale === locale,
children: app.data.locales[locale],
icon: app.data.locale === locale ? 'check' : true,
onclick: () => {
if (app.session.user) {
app.session.user.savePreferences({locale}).then(() => window.location.reload());
} else {
document.cookie = `locale=${locale}; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT`;
window.location.reload();
}
}
}
}));
}
items.add('locale', SelectDropdown.component({
children: locales,
buttonClassName: 'Button Button--link'
children: locales,
buttonClassName: 'Button Button--link'
}), 20);
}