From 76e8960f4ab30e91e7e9aca0ae82e10ba23d460d Mon Sep 17 00:00:00 2001 From: Martin Wortschack Date: Mon, 8 Apr 2019 14:17:45 +0000 Subject: Externalize strings in flash messages - Externalize strings in controllers - Update PO file --- app/controllers/abuse_reports_controller.rb | 6 +- app/controllers/application_controller.rb | 4 +- app/controllers/confirmations_controller.rb | 2 +- app/controllers/invites_controller.rb | 8 +- app/controllers/omniauth_callbacks_controller.rb | 12 +-- app/controllers/passwords_controller.rb | 4 +- app/controllers/profiles/chat_names_controller.rb | 10 +-- .../profiles/personal_access_tokens_controller.rb | 6 +- app/controllers/profiles/preferences_controller.rb | 6 +- .../profiles/u2f_registrations_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/controllers/sent_notifications_controller.rb | 2 +- app/controllers/sessions_controller.rb | 4 +- locale/gitlab.pot | 99 ++++++++++++++++++++++ 14 files changed, 133 insertions(+), 34 deletions(-) diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index 68e14f0c2e5..7d8016f763d 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -16,7 +16,7 @@ class AbuseReportsController < ApplicationController if @abuse_report.save @abuse_report.notify - message = "Thank you for your report. A GitLab administrator will look into it shortly." + message = _("Thank you for your report. A GitLab administrator will look into it shortly.") redirect_to @abuse_report.user, notice: message else render :new @@ -37,9 +37,9 @@ class AbuseReportsController < ApplicationController @user = User.find_by(id: params[:user_id]) if @user.nil? - redirect_to root_path, alert: "Cannot create the abuse report. The user has been deleted." + redirect_to root_path, alert: _("Cannot create the abuse report. The user has been deleted.") elsif @user.blocked? - redirect_to @user, alert: "Cannot create the abuse report. This user has been blocked." + redirect_to @user, alert: _("Cannot create the abuse report. This user has been blocked.") end end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b7eb6af6d67..d5f1e35a79b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -293,7 +293,7 @@ class ApplicationController < ActionController::Base unless Gitlab::Auth::LDAP::Access.allowed?(current_user) sign_out current_user - flash[:alert] = "Access denied for your LDAP account." + flash[:alert] = _("Access denied for your LDAP account.") redirect_to new_user_session_path end end @@ -340,7 +340,7 @@ class ApplicationController < ActionController::Base def require_email if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil? - return redirect_to profile_path, notice: 'Please complete your profile with email address' + return redirect_to profile_path, notice: _('Please complete your profile with email address') end end diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 2c4aab67448..2ae500a2fdf 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -22,7 +22,7 @@ class ConfirmationsController < Devise::ConfirmationsController after_sign_in(resource) else Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}") - flash[:notice] = flash[:notice] + " Please sign in." + flash[:notice] = flash[:notice] + _(" Please sign in.") new_session_path(:user, anchor: 'login-pane') end end diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 315d1375e02..a78d87eceea 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -13,9 +13,9 @@ class InvitesController < ApplicationController if member.accept_invite!(current_user) label, path = source_info(member.source) - redirect_to path, notice: "You have been granted #{member.human_access} access to #{label}." + redirect_to path, notice: _("You have been granted %{member_human_access} access to %{label}.") % { member_human_access: member.human_access, label: label } else - redirect_back_or_default(options: { alert: "The invitation could not be accepted." }) + redirect_back_or_default(options: { alert: _("The invitation could not be accepted.") }) end end @@ -30,9 +30,9 @@ class InvitesController < ApplicationController new_user_session_path end - redirect_to path, notice: "You have declined the invitation to join #{label}." + redirect_to path, notice: _("You have declined the invitation to join %{label}.") % { label: label } else - redirect_back_or_default(options: { alert: "The invitation could not be declined." }) + redirect_back_or_default(options: { alert: _("The invitation could not be declined.") }) end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index e90e8278c13..d9b3b4bbbd9 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -105,11 +105,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def redirect_identity_link_failed(error_message) - redirect_to profile_account_path, notice: "Authentication failed: #{error_message}" + redirect_to profile_account_path, notice: _("Authentication failed: %{error_message}") % { error_message: error_message } end def redirect_identity_linked - redirect_to profile_account_path, notice: 'Authentication method updated' + redirect_to profile_account_path, notice: _('Authentication method updated') end def handle_service_ticket(provider, ticket) @@ -147,10 +147,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController def handle_signup_error label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider']) - message = ["Signing in using your #{label} account without a pre-existing GitLab account is not allowed."] + message = [_("Signing in using your %{label} account without a pre-existing GitLab account is not allowed.") % { label: label }] if Gitlab::CurrentSettings.allow_signup? - message << "Create a GitLab account first, and then connect it to your #{label} account." + message << _("Create a GitLab account first, and then connect it to your %{label} account.") % { label: label } end flash[:notice] = message.join(' ') @@ -168,14 +168,14 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def fail_auth0_login - flash[:alert] = 'Wrong extern UID provided. Make sure Auth0 is configured correctly.' + flash[:alert] = _('Wrong extern UID provided. Make sure Auth0 is configured correctly.') redirect_to new_user_session_path end def handle_disabled_provider label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider']) - flash[:alert] = "Signing in using #{label} has been disabled" + flash[:alert] = _("Signing in using %{label} has been disabled") % { label: label } redirect_to new_user_session_path end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 28f113b5cbe..77de5cb45c9 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -22,7 +22,7 @@ class PasswordsController < Devise::PasswordsController ).first_or_initialize unless user.reset_password_period_valid? - flash[:alert] = 'Your password reset token has expired.' + flash[:alert] = _('Your password reset token has expired.') redirect_to(new_user_password_url(user_email: user['email'])) end end @@ -52,7 +52,7 @@ class PasswordsController < Devise::PasswordsController end redirect_to after_sending_reset_password_instructions_path_for(resource_name), - alert: "Password authentication is unavailable." + alert: _("Password authentication is unavailable.") end def throttle_reset diff --git a/app/controllers/profiles/chat_names_controller.rb b/app/controllers/profiles/chat_names_controller.rb index 2e78b9e6dc7..80b8279e91e 100644 --- a/app/controllers/profiles/chat_names_controller.rb +++ b/app/controllers/profiles/chat_names_controller.rb @@ -15,9 +15,9 @@ class Profiles::ChatNamesController < Profiles::ApplicationController new_chat_name = current_user.chat_names.new(chat_name_params) if new_chat_name.save - flash[:notice] = "Authorized #{new_chat_name.chat_name}" + flash[:notice] = _("Authorized %{new_chat_name}") % { new_chat_name: new_chat_name.chat_name } else - flash[:alert] = "Could not authorize chat nickname. Try again!" + flash[:alert] = _("Could not authorize chat nickname. Try again!") end delete_chat_name_token @@ -27,7 +27,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController def deny delete_chat_name_token - flash[:notice] = "Denied authorization of chat nickname #{chat_name_params[:user_name]}." + flash[:notice] = _("Denied authorization of chat nickname %{user_name}.") % { user_name: chat_name_params[:user_name] } redirect_to profile_chat_names_path end @@ -36,9 +36,9 @@ class Profiles::ChatNamesController < Profiles::ApplicationController @chat_name = chat_names.find(params[:id]) if @chat_name.destroy - flash[:notice] = "Deleted chat nickname: #{@chat_name.chat_name}!" + flash[:notice] = _("Deleted chat nickname: %{chat_name}!") % { chat_name: @chat_name.chat_name } else - flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}." + flash[:alert] = _("Could not delete chat nickname %{chat_name}.") % { chat_name: @chat_name.chat_name } end redirect_to profile_chat_names_path, status: :found diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb index 4b6ec2697b7..213d900a563 100644 --- a/app/controllers/profiles/personal_access_tokens_controller.rb +++ b/app/controllers/profiles/personal_access_tokens_controller.rb @@ -11,7 +11,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController if @personal_access_token.save PersonalAccessToken.redis_store!(current_user.id, @personal_access_token.token) - redirect_to profile_personal_access_tokens_path, notice: "Your new personal access token has been created." + redirect_to profile_personal_access_tokens_path, notice: _("Your new personal access token has been created.") else set_index_vars render :index @@ -22,9 +22,9 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController @personal_access_token = finder.find(params[:id]) if @personal_access_token.revoke! - flash[:notice] = "Revoked personal access token #{@personal_access_token.name}!" + flash[:notice] = _("Revoked personal access token %{personal_access_token_name}!") % { personal_access_token_name: @personal_access_token.name } else - flash[:alert] = "Could not revoke personal access token #{@personal_access_token.name}." + flash[:alert] = _("Could not revoke personal access token %{personal_access_token_name}.") % { personal_access_token_name: @personal_access_token.name } end redirect_to profile_personal_access_tokens_path diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb index 0227af2c266..0e30df1b15b 100644 --- a/app/controllers/profiles/preferences_controller.rb +++ b/app/controllers/profiles/preferences_controller.rb @@ -11,13 +11,13 @@ class Profiles::PreferencesController < Profiles::ApplicationController result = Users::UpdateService.new(current_user, preferences_params.merge(user: user)).execute if result[:status] == :success - flash[:notice] = 'Preferences saved.' + flash[:notice] = _('Preferences saved.') else - flash[:alert] = 'Failed to save preferences.' + flash[:alert] = _('Failed to save preferences.') end rescue ArgumentError => e # Raised when `dashboard` is given an invalid value. - flash[:alert] = "Failed to save preferences (#{e.message})." + flash[:alert] = _("Failed to save preferences (%{error_message}).") % { error_message: e.message } end respond_to do |format| diff --git a/app/controllers/profiles/u2f_registrations_controller.rb b/app/controllers/profiles/u2f_registrations_controller.rb index e6a154fb6aa..866c4dee6e2 100644 --- a/app/controllers/profiles/u2f_registrations_controller.rb +++ b/app/controllers/profiles/u2f_registrations_controller.rb @@ -4,6 +4,6 @@ class Profiles::U2fRegistrationsController < Profiles::ApplicationController def destroy u2f_registration = current_user.u2f_registrations.find(params[:id]) u2f_registration.destroy - redirect_to profile_two_factor_auth_path, status: 302, notice: "Successfully deleted U2F device." + redirect_to profile_two_factor_auth_path, status: 302, notice: _("Successfully deleted U2F device.") end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 8b8d87524a8..0fa4677ced1 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -27,7 +27,7 @@ class RegistrationsController < Devise::RegistrationsController persist_accepted_terms_if_required(new_user) end else - flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' + flash[:alert] = s_('Profiles|There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.') flash.delete :recaptcha_error render action: 'new' end diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb index 2b76921ebd8..77757c4a3ef 100644 --- a/app/controllers/sent_notifications_controller.rb +++ b/app/controllers/sent_notifications_controller.rb @@ -16,7 +16,7 @@ class SentNotificationsController < ApplicationController noteable = @sent_notification.noteable noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project) - flash[:notice] = "You have been unsubscribed from this thread." + flash[:notice] = _("You have been unsubscribed from this thread.") if current_user redirect_to noteable_path(noteable) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 4bd7d71e264..6943795e8ac 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -70,7 +70,7 @@ class SessionsController < Devise::SessionsController increment_failed_login_captcha_counter self.resource = resource_class.new - flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' + flash[:alert] = _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.') flash.delete :recaptcha_error respond_with_navigational(resource) { render :new } @@ -122,7 +122,7 @@ class SessionsController < Devise::SessionsController end redirect_to edit_user_password_path(reset_password_token: @token), - notice: "Please create a password for your new account." + notice: _("Please create a password for your new account.") end # rubocop: enable CodeReuse/ActiveRecord diff --git a/locale/gitlab.pot b/locale/gitlab.pot index f22b351ad78..aa116a44254 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -16,6 +16,9 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +msgid " Please sign in." +msgstr "" + msgid " Status" msgstr "" @@ -408,6 +411,9 @@ msgstr "" msgid "Access Tokens" msgstr "" +msgid "Access denied for your LDAP account." +msgstr "" + msgid "Access denied! Please verify you can add deploy keys to this repository." msgstr "" @@ -1008,12 +1014,18 @@ msgstr "" msgid "Authentication Log" msgstr "" +msgid "Authentication failed: %{error_message}" +msgstr "" + msgid "Authentication log" msgstr "" msgid "Authentication method" msgstr "" +msgid "Authentication method updated" +msgstr "" + msgid "Authentication via U2F device failed." msgstr "" @@ -1032,6 +1044,9 @@ msgstr "" msgid "Authorize %{link_to_client} to use your account?" msgstr "" +msgid "Authorized %{new_chat_name}" +msgstr "" + msgid "Authorized At" msgstr "" @@ -1467,6 +1482,12 @@ msgstr "" msgid "Cannot be merged automatically" msgstr "" +msgid "Cannot create the abuse report. The user has been deleted." +msgstr "" + +msgid "Cannot create the abuse report. This user has been blocked." +msgstr "" + msgid "Cannot modify managed Kubernetes cluster" msgstr "" @@ -2525,12 +2546,18 @@ msgstr "" msgid "Copy token to clipboard" msgstr "" +msgid "Could not authorize chat nickname. Try again!" +msgstr "" + msgid "Could not connect to FogBugz, check your URL" msgstr "" msgid "Could not create Wiki Repository at this time. Please try again later." msgstr "" +msgid "Could not delete chat nickname %{chat_name}." +msgstr "" + msgid "Could not remove the trigger." msgstr "" @@ -2540,6 +2567,9 @@ msgstr "" msgid "Could not revoke impersonation token %{token_name}." msgstr "" +msgid "Could not revoke personal access token %{personal_access_token_name}." +msgstr "" + msgid "Coverage" msgstr "" @@ -2552,6 +2582,9 @@ msgstr "" msgid "Create New Domain" msgstr "" +msgid "Create a GitLab account first, and then connect it to your %{label} account." +msgstr "" + msgid "Create a new branch" msgstr "" @@ -2804,6 +2837,12 @@ msgstr "" msgid "Deleted" msgstr "" +msgid "Deleted chat nickname: %{chat_name}!" +msgstr "" + +msgid "Denied authorization of chat nickname %{user_name}." +msgstr "" + msgid "Deny" msgstr "" @@ -3643,6 +3682,12 @@ msgstr "" msgid "Failed to save new settings" msgstr "" +msgid "Failed to save preferences (%{error_message})." +msgstr "" + +msgid "Failed to save preferences." +msgstr "" + msgid "Failed to update issues, please try again." msgstr "" @@ -5800,6 +5845,9 @@ msgstr "" msgid "Password" msgstr "" +msgid "Password authentication is unavailable." +msgstr "" + msgid "Past due" msgstr "" @@ -6067,12 +6115,18 @@ msgstr "" msgid "Please choose a group URL with no special characters." msgstr "" +msgid "Please complete your profile with email address" +msgstr "" + msgid "Please convert them to %{link_to_git}, and go through the %{link_to_import_flow} again." msgstr "" msgid "Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again." msgstr "" +msgid "Please create a password for your new account." +msgstr "" + msgid "Please create a username with only alphanumeric characters." msgstr "" @@ -6106,6 +6160,9 @@ msgstr "" msgid "Preferences" msgstr "" +msgid "Preferences saved." +msgstr "" + msgid "Preferences|Navigation theme" msgstr "" @@ -6298,6 +6355,9 @@ msgstr "" msgid "Profiles|The maximum file size allowed is 200KB." msgstr "" +msgid "Profiles|There was an error with the reCAPTCHA. Please solve the reCAPTCHA again." +msgstr "" + msgid "Profiles|This doesn't look like a public SSH key, are you sure you want to add it?" msgstr "" @@ -6992,6 +7052,9 @@ msgstr "" msgid "Revoked impersonation token %{token_name}!" msgstr "" +msgid "Revoked personal access token %{personal_access_token_name}!" +msgstr "" + msgid "Run untagged jobs" msgstr "" @@ -7480,6 +7543,12 @@ msgstr "" msgid "Sign-up restrictions" msgstr "" +msgid "Signing in using %{label} has been disabled" +msgstr "" + +msgid "Signing in using your %{label} account without a pre-existing GitLab account is not allowed." +msgstr "" + msgid "Similar issues" msgstr "" @@ -7882,6 +7951,9 @@ msgstr "" msgid "Successfully confirmed" msgstr "" +msgid "Successfully deleted U2F device." +msgstr "" + msgid "Successfully removed email." msgstr "" @@ -8047,6 +8119,9 @@ msgstr "" msgid "Test failed." msgstr "" +msgid "Thank you for your report. A GitLab administrator will look into it shortly." +msgstr "" + msgid "The %{type} contains the following error:" msgid_plural "The %{type} contains the following errors:" msgstr[0] "" @@ -8109,6 +8184,12 @@ msgstr "" msgid "The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination." msgstr "" +msgid "The invitation could not be accepted." +msgstr "" + +msgid "The invitation could not be declined." +msgstr "" + msgid "The invitation has already been accepted." msgstr "" @@ -9465,6 +9546,9 @@ msgstr "" msgid "Write milestone description..." msgstr "" +msgid "Wrong extern UID provided. Make sure Auth0 is configured correctly." +msgstr "" + msgid "Yes" msgstr "" @@ -9591,6 +9675,15 @@ msgstr "" msgid "You don't have any deployments right now." msgstr "" +msgid "You have been granted %{member_human_access} access to %{label}." +msgstr "" + +msgid "You have been unsubscribed from this thread." +msgstr "" + +msgid "You have declined the invitation to join %{label}." +msgstr "" + msgid "You have no permissions" msgstr "" @@ -9747,6 +9840,12 @@ msgstr "" msgid "Your name" msgstr "" +msgid "Your new personal access token has been created." +msgstr "" + +msgid "Your password reset token has expired." +msgstr "" + msgid "Your project limit is %{limit} projects! Please contact your administrator to increase it" msgstr "" -- cgit v1.2.1