forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented issue zammad#1171 - The ability to set the platform defau…
…lt language.
- Loading branch information
Showing
21 changed files
with
198 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/assets/javascripts/app/controllers/_settings/area_item_default_locale.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class App.SettingsAreaItemDefaultLocale extends App.SettingsAreaItem | ||
|
||
render: => | ||
|
||
options = {} | ||
locales = App.Locale.all() | ||
for locale in locales | ||
options[locale.locale] = locale.name | ||
configure_attributes = [ | ||
{ name: 'locale_default', display: '', tag: 'searchable_select', null: false, class: 'input', options: options, default: @setting.state_current.value }, | ||
] | ||
|
||
@html App.view(@template)( | ||
setting: @setting | ||
) | ||
|
||
new App.ControllerForm( | ||
el: @el.find('.form-item') | ||
model: { configure_attributes: configure_attributes, className: '' } | ||
autofocus: false | ||
) |
23 changes: 23 additions & 0 deletions
23
app/assets/javascripts/app/controllers/widget/default_locale.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class DefaultLocale extends App.Controller | ||
constructor: -> | ||
super | ||
|
||
check = => | ||
|
||
preferences = App.Session.get('preferences') | ||
return if !preferences | ||
return if !_.isEmpty(preferences.locale) | ||
locale = App.i18n.get() | ||
@ajax( | ||
id: "i18n-set-user-#{locale}" | ||
type: 'PUT' | ||
url: "#{App.Config.get('api_path')}/users/preferences" | ||
data: JSON.stringify(locale: locale) | ||
processData: true | ||
) | ||
|
||
App.Event.bind('auth:login', (session) => | ||
@delay(check, 3500, 'default_locale') | ||
) | ||
|
||
App.Config.set('default_locale', DefaultLocale, 'Widgets') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class SettingDefaultLocale < ActiveRecord::Migration[5.1] | ||
def up | ||
|
||
# return if it's a new setup | ||
return if !Setting.find_by(name: 'system_init_done') | ||
|
||
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 | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.