-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internationalize/I18n the Dashboard Engine #497
Changes from 1 commit
cd6539c
7565c20
de6fccd
8e45d39
efcc43f
e23bef8
4d9a1e4
35d27a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
CHANGELOG_GITHUB_TOKEN= | ||
GOOGLE_TRANSLATE_API_KEY= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks | ||
|
||
# The "main" locale. | ||
base_locale: en | ||
## All available locales are inferred from the data by default. Alternatively, specify them explicitly: | ||
# locales: [es, fr] | ||
## Reporting locale, default: en. Available: en, ru. | ||
# internal_locale: en | ||
|
||
# Read and write translations. | ||
data: | ||
read: | ||
- engine/config/locales/%{locale}.yml | ||
- engine/config/locales/**/*.%{locale}.yml | ||
|
||
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom: | ||
# `i18n-tasks normalize -p` will force move the keys according to these rules | ||
write: | ||
## For example, write devise and simple form keys to their respective files: | ||
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml'] | ||
## Catch-all default: | ||
# - config/locales/%{locale}.yml | ||
|
||
# External locale data (e.g. gems). | ||
# This data is not considered unused and is never written to. | ||
external: | ||
## Example (replace %#= with %=): | ||
# - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml" | ||
|
||
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class. | ||
# router: conservative_router | ||
|
||
yaml: | ||
write: | ||
# do not wrap lines at 80 characters | ||
line_width: -1 | ||
|
||
## Pretty-print JSON: | ||
# json: | ||
# write: | ||
# indent: ' ' | ||
# space: ' ' | ||
# object_nl: "\n" | ||
# array_nl: "\n" | ||
|
||
# Find translate calls | ||
search: | ||
paths: | ||
- engine/app | ||
relative_roots: | ||
- engine/app/controllers | ||
- engine/app/helpers | ||
- engine/app/views | ||
|
||
## Directories where method names which should not be part of a relative key resolution. | ||
# By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key. | ||
# Directories listed here will not consider the name of the method part of the resolved key | ||
# | ||
# relative_exclude_method_name_paths: | ||
# - | ||
|
||
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting: | ||
## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json *.map) | ||
exclude: | ||
- app/assets/images | ||
- app/assets/fonts | ||
- app/assets/videos | ||
|
||
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`: | ||
## If specified, this settings takes priority over `exclude`, but `exclude` still applies. | ||
# only: ["*.rb", "*.html.slim"] | ||
|
||
## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`. | ||
# strict: true | ||
|
||
## Multiple scanners can be used. Their results are merged. | ||
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well. | ||
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example | ||
|
||
## Translation Services | ||
# translation: | ||
# # Google Translate | ||
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate | ||
# google_translate_api_key: "AbC-dEf5" | ||
# # DeepL Pro Translate | ||
# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro | ||
# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A" | ||
# # deepl_host: "https://api.deepl.com" | ||
# # deepl_version: "v2" | ||
|
||
## Do not consider these keys missing: | ||
# ignore_missing: | ||
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}' | ||
# - '{devise,simple_form}.*' | ||
|
||
## Consider these keys used: | ||
ignore_unused: | ||
- "activerecord.attributes.*" | ||
- "datetime.*" | ||
|
||
## Exclude these keys from the `i18n-tasks eq-base' report: | ||
# ignore_eq_base: | ||
# all: | ||
# - common.ok | ||
# fr,es: | ||
# - common.brand | ||
|
||
## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report: | ||
# ignore_inconsistent_interpolations: | ||
# - 'activerecord.attributes.*' | ||
|
||
## Ignore these keys completely: | ||
# ignore: | ||
# - kaminari.* | ||
|
||
## Sometimes, it isn't possible for i18n-tasks to match the key correctly, | ||
## e.g. in case of a relative key defined in a helper method. | ||
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.: | ||
# | ||
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper', | ||
# only: %w(*.html.haml *.html.slim), | ||
# patterns: [['= title\b', '.page_title']] %> | ||
# | ||
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.: | ||
# | ||
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper', | ||
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ module GoodJob | |
class BaseController < ActionController::Base # rubocop:disable Rails/ApplicationController | ||
protect_from_forgery with: :exception | ||
|
||
before_action :set_locale | ||
around_action :switch_locale | ||
|
||
content_security_policy do |policy| | ||
policy.default_src(:none) if policy.default_src(*policy.default_src).blank? | ||
|
@@ -30,8 +30,8 @@ def default_url_options(options = {}) | |
|
||
private | ||
|
||
def set_locale | ||
I18n.locale = current_locale | ||
def switch_locale(&action) | ||
I18n.with_locale(current_locale, &action) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I like that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know, yes, we don't want unexpected behavior 👍 Thank you for the info |
||
end | ||
|
||
def current_locale | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
--- | ||
en: | ||
datetime: | ||
distance_in_words: | ||
about_x_hours: | ||
one: about 1 hour | ||
other: about %{count} hours | ||
about_x_months: | ||
one: about 1 month | ||
other: about %{count} months | ||
about_x_years: | ||
one: about 1 year | ||
other: about %{count} years | ||
almost_x_years: | ||
one: almost 1 year | ||
other: almost %{count} years | ||
half_a_minute: half a minute | ||
less_than_x_minutes: | ||
one: less than a minute | ||
other: less than %{count} minutes | ||
less_than_x_seconds: | ||
one: less than 1 second | ||
other: less than %{count} seconds | ||
over_x_years: | ||
one: over 1 year | ||
other: over %{count} years | ||
x_days: | ||
one: 1 day | ||
other: "%{count} days" | ||
x_minutes: | ||
one: 1 minute | ||
other: "%{count} minutes" | ||
x_months: | ||
one: 1 month | ||
other: "%{count} months" | ||
x_seconds: | ||
one: 1 second | ||
other: "%{count} seconds" | ||
x_years: | ||
one: 1 year | ||
other: "%{count} years" | ||
good_job: | ||
shared: | ||
announcement: | ||
work_in_progress_html: "🚧 GoodJob's dashboard is a work in progress. Please contribute ideas and code on <a href=\"https://github.com/bensheldon/good_job/issues\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Github</a>." | ||
footer: | ||
last_update_html: Last updated <time id="page-updated-at" datetime="%{time}">%{time}</time> | ||
wording: Remember, you're doing a Good Job too! | ||
navbar: | ||
commig_soon: More views coming soon | ||
coming_soon: More views coming soon | ||
cron_schedules: Cron Schedules | ||
current_time: Now is %{time} | ||
executions: All Executions | ||
jobs: All Jobs | ||
name: GoodJob 👍 | ||
processes: Processes | ||
live_poll: Live Poll | ||
announcement: | ||
work_in_progress_html: 🚧 GoodJob's dashboard is a work in progress. Please contribute ideas and code on <a href="https://github.com/bensheldon/good_job/issues" target="_blank" rel="nofollow noopener noreferrer">Github</a>. | ||
footer: | ||
last_update_html: Last updated <time id="page-updated-at" datetime="%{time}">%{time}</time> | ||
wording: Remember, you're doing a Good Job too! | ||
name: "GoodJob 👍" | ||
processes: Processes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you prefer
around_action
overbefore_action
?