Skip to content

Commit

Permalink
Allow for the Default Language to be changed (#294)
Browse files Browse the repository at this point in the history
* Allow the default locale to be changed

* Add instructions on changing default locale

* Grammar
  • Loading branch information
pglombardo authored Feb 27, 2022
1 parent 8a6105d commit 718dd2d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ RAILS_ENV=private ./bin/rake db:setup

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

# Internationalization

Password Pusher is currently available in **13 languages** with more languages being added often as volunteers apply.

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.

## Changing the Default Language

The default language can be changed by setting an environment variable with the appropriate language code:

PWP__DEFAULT_LOCALE=es

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).

# 📼 Credits

## Translators
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
I18n.available_locales = %i[ca da de en es fr it nl no pl pt-BR sr sv]

# Set default locale to something other than :en
I18n.default_locale = :en
I18n.default_locale = Settings.default_locale

TranslationIO.configure do |config|
config.api_key = 'cc6a66a15e02433aa9d0afeb39835b8c'
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
get '/slack_direct_install', to: redirect("https://slack.com/oauth/authorize?client_id=#{SLACK_CLIENT_ID}&scope=commands", status: 302)
get '/pages/*id' => 'pages#show', as: :page, format: false
resources :feedbacks, only: %i[new create]
root to: 'passwords#new'
root to: 'passwords#new', :locale => I18n.default_locale
end
end
17 changes: 14 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# this new config gem, then we'll migrate entirely to the new Settings
# format for private instances too.

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

# The domain (without protocol) where this instance is hosted
Expand Down Expand Up @@ -36,6 +37,10 @@ mail:
# See config/initializers/devise.rb where this is used
# mailer_sender: '"Password Pusher" <[email protected]>'

# List of supported languages indexed by language code. This is used
# to build the in application language menu.
#
# <language code>: '<language name>'
language_codes:
ca: 'Català'
da: 'Dansk'
Expand All @@ -51,3 +56,9 @@ language_codes:
sr: 'Српски'
sv: 'Svenska'

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

0 comments on commit 718dd2d

Please sign in to comment.