diff --git a/Rakefile b/Rakefile index 51b787b..4ebc6d5 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ require "bundler" require "rake" require "rspec/core" require "rspec/core/rake_task" +require "yaml" begin Bundler.setup(:default, :development) @@ -15,4 +16,37 @@ RSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = FileList["spec/**/*_spec.rb"] end +def en_locale + @en_locale ||= YAML.load_file(File.join("rails", "locales", "en.yml")) +end + +def merge_locales(source, target) + source.inject({}) do |locale, (key, value)| + if value.is_a?(Hash) + locale[key] = merge_locales(value, target[key] || {}) + else + locale[key] = target[key].nil? ? source[key] : target[key] + end + + locale + end +end + task default: :spec + +task :fill do + Dir.glob(File.join("rails", "locales", "*.yml")).each do |file| + next if File.basename(file) == "en.yml" + + puts "Processing #{File.basename(file)}" + + locale = YAML.load_file(file) + lang = locale.keys.first.dup + + merged_locale = merge_locales(en_locale.fetch("en"), locale.fetch(lang)) + + File.open(file, "w") do |f| + f.write(YAML.dump({ lang => merged_locale }, line_width: -1).gsub("---\n", '')) + end + end +end \ No newline at end of file diff --git a/rails/locales/en.yml b/rails/locales/en.yml index 5fba6e6..fed6409 100644 --- a/rails/locales/en.yml +++ b/rails/locales/en.yml @@ -4,7 +4,6 @@ en: doorkeeper/application: name: 'Name' redirect_uri: 'Redirect URI' - scopes: 'Scopes' errors: models: doorkeeper/application: @@ -18,7 +17,6 @@ en: forbidden_uri: 'is forbidden by the server.' scopes: not_match_configured: "doesn't match configured on the server." - doorkeeper: applications: confirmations: @@ -52,13 +50,14 @@ en: title: 'New Application' show: title: 'Application: %{name}' - application_id: 'Application UID' + application_id: 'UID' secret: 'Secret' + secret_hashed: 'Secret hashed' scopes: 'Scopes' confidential: 'Confidential' callback_urls: 'Callback urls' actions: 'Actions' - + not_defined: 'Not defined' authorizations: buttons: authorize: 'Authorize' @@ -71,7 +70,8 @@ en: able_to: 'This application will be able to' show: title: 'Authorization code' - + form_post: + title: 'Submit this form' authorized_applications: confirmations: revoke: 'Are you sure?' @@ -82,13 +82,10 @@ en: application: 'Application' created_at: 'Created At' date_format: '%Y-%m-%d %H:%M:%S' - pre_authorization: status: 'Pre-authorization' - errors: messages: - # Common error messages invalid_request: unknown: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.' missing_param: 'Missing required parameter: %{value}.' @@ -100,20 +97,14 @@ en: invalid_code_challenge_method: 'The code challenge method must be plain or S256.' server_error: 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.' temporarily_unavailable: 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.' - - # Configuration error messages credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.' resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfigured.' admin_authenticator_not_configured: 'Access to admin panel is forbidden due to Doorkeeper.configure.admin_authenticator being unconfigured.' - - # Access grant errors unsupported_response_type: 'The authorization server does not support this response type.' - - # Access token errors + unsupported_response_mode: 'The authorization server does not support this response mode.' invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.' invalid_grant: 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.' unsupported_grant_type: 'The authorization grant type is not supported by the authorization server.' - invalid_token: revoked: "The access token was revoked" expired: "The access token expired" @@ -122,7 +113,6 @@ en: unauthorized: "You are not authorized to revoke this token" forbidden_token: missing_scope: 'Access to this resource requires scope "%{oauth_scopes}".' - flash: applications: create: @@ -134,7 +124,6 @@ en: authorized_applications: destroy: notice: 'Application revoked.' - layouts: admin: title: 'Doorkeeper'