Skip to content

Commit 718dd2d

Browse files
authored
Allow for the Default Language to be changed (#294)
* Allow the default locale to be changed * Add instructions on changing default locale * Grammar
1 parent 8a6105d commit 718dd2d

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ RAILS_ENV=private ./bin/rake db:setup
162162

163163
Then view the site @ [http://localhost:5100/](http://localhost:5100/).
164164

165+
# Internationalization
166+
167+
Password Pusher is currently available in **13 languages** with more languages being added often as volunteers apply.
168+
169+
From within the application, the language is selectable from a language menu. Out of the box and before any language menu selection is done, the default language for the application is English.
170+
171+
## Changing the Default Language
172+
173+
The default language can be changed by setting an environment variable with the appropriate language code:
174+
175+
PWP__DEFAULT_LOCALE=es
176+
177+
For more details, a list of supported language codes and further explanation, see the bottom of this [configuration file](https://github.com/pglombardo/PasswordPusher/blob/master/config/settings.yml).
178+
165179
# 📼 Credits
166180

167181
## Translators

config/initializers/translation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
I18n.available_locales = %i[ca da de en es fr it nl no pl pt-BR sr sv]
33

44
# Set default locale to something other than :en
5-
I18n.default_locale = :en
5+
I18n.default_locale = Settings.default_locale
66

77
TranslationIO.configure do |config|
88
config.api_key = 'cc6a66a15e02433aa9d0afeb39835b8c'

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
get '/slack_direct_install', to: redirect("https://slack.com/oauth/authorize?client_id=#{SLACK_CLIENT_ID}&scope=commands", status: 302)
3232
get '/pages/*id' => 'pages#show', as: :page, format: false
3333
resources :feedbacks, only: %i[new create]
34-
root to: 'passwords#new'
34+
root to: 'passwords#new', :locale => I18n.default_locale
3535
end
3636
end

config/settings.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# this new config gem, then we'll migrate entirely to the new Settings
55
# format for private instances too.
66

7-
# Logins are not yet supported in private instances yet due to a bit more support work
8-
# that needs to be done first.
9-
# e.g. how to hook up an email MTA. Coming soon.
7+
# Logins are disabled by default since they require an MTA (email) server
8+
# available to send emails through.
9+
# For instructions on how to enable logins, see this page:
10+
# https://github.com/pglombardo/PasswordPusher/discussions/276
1011
enable_logins: false
1112

1213
# The domain (without protocol) where this instance is hosted
@@ -36,6 +37,10 @@ mail:
3637
# See config/initializers/devise.rb where this is used
3738
# mailer_sender: '"Password Pusher" <pglombardo@pwpush.com>'
3839

40+
# List of supported languages indexed by language code. This is used
41+
# to build the in application language menu.
42+
#
43+
# <language code>: '<language name>'
3944
language_codes:
4045
ca: 'Català'
4146
da: 'Dansk'
@@ -51,3 +56,9 @@ language_codes:
5156
sr: 'Српски'
5257
sv: 'Svenska'
5358

59+
# The default language for the application. This must be one of the
60+
# valid/supported language codes from the list above.
61+
# Example: default_locale: :es
62+
# Environment Variable Override: PWP__DEFAULT_LOCALE='es'
63+
default_locale: :en
64+

0 commit comments

Comments
 (0)