Set locale_default at initial admin creation too.

This commit is contained in:
Martin Edenhofer 2017-12-06 15:31:27 +01:00
parent fd8511e44c
commit 6c0f7fc1e7
3 changed files with 33 additions and 21 deletions

View file

@ -240,6 +240,9 @@ class Admin extends App.WizardFullScreen
relogin: (data, status, xhr) => relogin: (data, status, xhr) =>
@log 'notice', 'relogin:success', data @log 'notice', 'relogin:success', data
callback = ->
App.Setting.set('locale_default', App.i18n.detectBrowserLocale())
App.Setting.fetchFull(callback)
App.Event.trigger 'notify:removeall' App.Event.trigger 'notify:removeall'
@navigate 'getting_started/base' @navigate 'getting_started/base'

View file

@ -1,13 +1,20 @@
class SettingDefaultLocale < ActiveRecord::Migration[5.1] class SettingDefaultLocale2 < ActiveRecord::Migration[5.1]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')
setting = Setting.find_by(name: 'locale_default')
if setting
setting.area = 'System::Branding'
setting.preferences[:prio] = 8
setting.save!
end
Setting.create_if_not_exists( Setting.create_if_not_exists(
title: 'Locale', title: 'Locale',
name: 'locale_default', name: 'locale_default',
area: 'System::Base', area: 'System::Branding',
description: 'Defines the system default language.', description: 'Defines the system default language.',
options: { options: {
form: [ form: [
@ -18,6 +25,7 @@ class SettingDefaultLocale < ActiveRecord::Migration[5.1]
}, },
state: 'en-us', state: 'en-us',
preferences: { preferences: {
prio: 8,
controller: 'SettingsAreaItemDefaultLocale', controller: 'SettingsAreaItemDefaultLocale',
permission: ['admin.system'], permission: ['admin.system'],
}, },

View file

@ -156,6 +156,26 @@ Setting.create_if_not_exists(
}, },
frontend: true frontend: true
) )
Setting.create_if_not_exists(
title: 'Locale',
name: 'locale_default',
area: 'System::Branding',
description: 'Defines the system default language.',
options: {
form: [
{
name: 'locale_default',
}
],
},
state: 'en-us',
preferences: {
prio: 8,
controller: 'SettingsAreaItemDefaultLocale',
permission: ['admin.system'],
},
frontend: true
)
Setting.create_or_update( Setting.create_or_update(
title: 'Pretty Date', title: 'Pretty Date',
name: 'pretty_date_format', name: 'pretty_date_format',
@ -183,25 +203,6 @@ Setting.create_or_update(
state: 'relative', state: 'relative',
frontend: true frontend: true
) )
Setting.create_if_not_exists(
title: 'Locale',
name: 'locale_default',
area: 'System::Base',
description: 'Defines the system default language.',
options: {
form: [
{
name: 'locale_default',
}
],
},
state: 'en-us',
preferences: {
controller: 'SettingsAreaItemDefaultLocale',
permission: ['admin.system'],
},
frontend: true
)
options = {} options = {}
(10..99).each do |item| (10..99).each do |item|
options[item] = item options[item] = item