rodauth-i18n 0.1.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca239979b32a8e406b1763945b5e9cc5f0eb2f806df1725b82067aa655e4818b
4
- data.tar.gz: 2bf9f5bd61fedd012269deea89b977a160b2b13299d825ccb7df6408e6c7fb4e
3
+ metadata.gz: ff0034b4e6b28f5822ecc9ee1698ab728995e0e063f78dbfbf0c9e8d0d819a84
4
+ data.tar.gz: 61899a57abb184b686676a27a215c89098a47b747801a02b651f097179055332
5
5
  SHA512:
6
- metadata.gz: ac9be630282bd3c016b7df99d0f5cf8ee86f327a7640748fa29fe4a4a87614a785133ab93589185231a717cc2cbe2f41ed281578451552c32a5a9c20cb06966f
7
- data.tar.gz: 32a4c1f74ac1fcbc5baf09198bb3178f6392bdd0b846fcf64c759bd5356d820670648d873f9446a9547734784abd9edd1688465058f62f9bf867cbdeb93adb6d
6
+ metadata.gz: 539e08db905e57c51b88d0b4619d9d330ec279dbb843dd4d042f2bfd20c81bcbd2d76a88b11e3796f4f0e37046467399547a5c97cf24a647d7dc660a18e11e77
7
+ data.tar.gz: b16c1407a6e3887297c52c938e4e4f1f0cf80db6e0a9f6d13390258130e67200969e82ea538e343c0944818d79fa8eeda400011e8fbfda21e3dc9ae7569fdd32
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # rodauth-i18n
2
2
 
3
- Provides [I18n] integration for [Rodauth] authentication framework. It also includes built-in translations, which you are welcome to extend.
3
+ Provides [I18n] integration for [Rodauth] authentication framework.
4
+
5
+ It also includes built-in translations for various languages, which you are encouraged to extend :pray:
4
6
 
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
9
11
  ```ruby
10
- gem "rodauth-i18n"
12
+ gem "rodauth-i18n", "~> 0.3"
11
13
  ```
12
14
 
13
15
  And then execute:
@@ -24,7 +26,7 @@ $ gem install rodauth-i18n
24
26
 
25
27
  ## Usage
26
28
 
27
- Enable the `i18n` feature in your Rodauth configuration:
29
+ Enable the `i18n` feature in your Rodauth configuration, which overrides Rodauth's `#translate` method to use the [I18n] gem.
28
30
 
29
31
  ```rb
30
32
  plugin :rodauth do
@@ -33,16 +35,7 @@ plugin :rodauth do
33
35
  end
34
36
  ```
35
37
 
36
- If you're using Rails, the built-in translations will be automatically loaded based on your configured available locales. Otherwise, you need to manually add them to I18n's load path before translations have been loaded:
37
-
38
- ```rb
39
- require "rodauth/i18n"
40
-
41
- # adds built-in locale files to I18n's load path
42
- Rodauth::I18n.add
43
- ```
44
-
45
- See the [Rails Internationalization Guide] on how to set the locale.
38
+ Enabling the feature will automatically load built-in translations for locales specified in `I18n.available_locales`. If unset, translations for *all* locales will be loaded.
46
39
 
47
40
  ### Per configuration translations
48
41
 
@@ -78,15 +71,20 @@ i18n_cascade? false
78
71
 
79
72
  ### Copying translations
80
73
 
81
- In Rails, you can copy built-in translations into your app via the `rodauth:i18n:translations` generator, which receives a list of locales to copy translations for:
74
+ In a Rails app, you can copy built-in translations into your app via the `rodauth:translations` generator. By default, it will import translations for available locales, but you can also give it a list of locales:
82
75
 
83
76
  ```sh
84
- $ rails generate rodauth:i18n:translations en hr
77
+ $ rails generate rodauth:translations en hr
85
78
  # create config/locales/rodauth.en.yml
86
79
  # create config/locales/rodauth.hr.yml
80
+
81
+ $ rails generate rodauth:translations
82
+ # imports translations for available locales
87
83
  ```
88
84
 
89
- Alternatively, you can copy the translation files directly from the `locales/` directory.
85
+ Only translations for currently enabled Rodauth features will be imported. Re-running the generator will import translations for any newly enabled features, remove translations for any disabled features, and keep any existing translations unchanged.
86
+
87
+ On other web frameworks, you can copy the translation files directly from the `locales/` directory.
90
88
 
91
89
  ### Raising on missing translations
92
90
 
@@ -104,6 +102,14 @@ In some cases it can be useful to fall back to untranslated value when the trans
104
102
  i18n_fallback_to_untranslated? { Rails.env.production? }
105
103
  ```
106
104
 
105
+ ### Available locales
106
+
107
+ If you want to load translations for a set of locales different than `I18n.available_locales`, you can configure that:
108
+
109
+ ```rb
110
+ i18n_available_locales [:en, :pt]
111
+ ```
112
+
107
113
  ### Overriding current locale
108
114
 
109
115
  The current locale defaults to `I18n.locale`, but you can override that:
@@ -120,6 +126,77 @@ You can pass any custom options to the `I18n.translate` method via `i18n_options
120
126
  i18n_options { { exception_handler: -> (*args) { ... } } }
121
127
  ```
122
128
 
129
+ ## Localized routes
130
+
131
+ If you want to prefix your routes with current locale, you can do so as
132
+ follows:
133
+
134
+ ```rb
135
+ prefix do
136
+ if I18n.locale == I18n.default_locale
137
+ "/auth"
138
+ else
139
+ "/#{I18n.locale}/auth"
140
+ end
141
+ end
142
+ ```
143
+ ```rb
144
+ route do |r|
145
+ # ...
146
+ all_locales = I18n.available_locales.map(&:to_s) - [I18n.default_locale.to_s]
147
+ # routes requests starting with `(/:locale)/auth/*`
148
+ r.on [*all_locales, true], "auth" do |locale|
149
+ rails_request.params[:locale] = locale || I18n.default_locale # if using Rails
150
+ r.rodauth
151
+ break
152
+ end
153
+ end
154
+ ```
155
+
156
+ ## Bundling translations in your Rodauth plugin
157
+
158
+ To make texts in your Rodauth plugin translatable, use the `translatable_method` macro. Macros for defining flash messages, button texts, and page titles internally call `translatable_method`, and are thus automatically translatable.
159
+
160
+ ```rb
161
+ # lib/rodauth/features/foo.rb
162
+ module Rodauth
163
+ Feature.define(:foo, :Foo) do
164
+ translatable_method :foo_message, "This message is translatable"
165
+ error_flash "Flash messages are automatically translatable", "foo"
166
+ button "Translatable button text", "foo"
167
+ view "foo", "Translatable page title", "foo"
168
+ end
169
+ end
170
+ ```
171
+
172
+ You can then define translations in the `locales/` directory in your gem root:
173
+
174
+ ```yml
175
+ # locales/en.yml
176
+ en:
177
+ rodauth:
178
+ foo_message: "..."
179
+ foo_error_flash: "..."
180
+ foo_button: "..."
181
+ foo_page_title: "..."
182
+ ```
183
+
184
+ Then, to have rodauth-i18n load your translations, register the directory when loading the feature:
185
+
186
+ ```rb
187
+ # lib/rodauth/features/foo.rb
188
+ module Rodauth
189
+ Feature.define(:foo, :Foo) do
190
+ # ...
191
+ def post_configure
192
+ super
193
+ i18n_register File.expand_path("#{__dir__}/../../../locales") if features.include?(:i18n)
194
+ end
195
+ # ...
196
+ end
197
+ end
198
+ ```
199
+
123
200
  ## Development
124
201
 
125
202
  Run tests with Rake:
@@ -0,0 +1,90 @@
1
+ require "rails/generators"
2
+ require "active_support/core_ext/hash/slice"
3
+
4
+ module Rodauth
5
+ module Rails
6
+ class TranslationsGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path("#{__dir__}/../../../locales")
8
+ namespace "rodauth:translations"
9
+
10
+ argument :selected_locales, type: :array, required: false,
11
+ desc: "List of locales to copy translation files for"
12
+
13
+ def copy_locales
14
+ say "No locales specified!", :yellow if locales.empty?
15
+
16
+ locales.each do |locale|
17
+ translations = retrieve_translations(locale)
18
+
19
+ if translations.empty?
20
+ say "No translations for locale: #{locale}", :yellow
21
+ next
22
+ end
23
+
24
+ # retain translations the user potentially changed
25
+ translations.merge!(existing_translations(locale))
26
+ # keep only translations for currently enabled features
27
+ translations.slice!(*rodauth_methods)
28
+
29
+ create_file "config/locales/rodauth.#{locale}.yml", locale_content(locale, translations)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def retrieve_translations(locale)
36
+ files = translation_files(locale)
37
+ files.inject({}) do |translations, file|
38
+ translations.merge YAML.load_file(file)[locale]["rodauth"]
39
+ end
40
+ end
41
+
42
+ def existing_translations(locale)
43
+ destination = File.join(destination_root, "config/locales/rodauth.#{locale}.yml")
44
+
45
+ # try to load existing translations first
46
+ if File.exist?(destination)
47
+ YAML.load_file(destination)[locale]["rodauth"]
48
+ else
49
+ {}
50
+ end
51
+ end
52
+
53
+ def translation_files(locale)
54
+ # ensure Rodauth configuration ran in autoloaded environment
55
+ Rodauth::Rails.app
56
+
57
+ Rodauth::I18n.directories
58
+ .map { |directory| Dir["#{directory}/#{locale}.yml"] }
59
+ .inject(:+)
60
+ end
61
+
62
+ def rodauth_methods
63
+ rodauths
64
+ .flat_map { |rodauth| rodauth.instance_methods - Object.instance_methods }
65
+ .map(&:to_s)
66
+ .sort
67
+ end
68
+
69
+ def locale_content(locale, translations)
70
+ data = { locale => { "rodauth" => translations } }
71
+ yaml = YAML.dump(data, line_width: 10_000) # disable line wrapping
72
+ yaml.split("\n", 2).last # remove "---" header
73
+ end
74
+
75
+ def locales
76
+ selected_locales || available_locales.map(&:to_s)
77
+ end
78
+
79
+ def available_locales
80
+ rodauths.inject([]) do |locales, rodauth|
81
+ locales |= rodauth.allocate.send(:i18n_available_locales) || []
82
+ end
83
+ end
84
+
85
+ def rodauths
86
+ Rodauth::Rails.app.opts[:rodauths].values
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1 +1,107 @@
1
- require "rodauth/i18n/feature"
1
+ require "set"
2
+ require "i18n"
3
+
4
+ module Rodauth
5
+ Feature.define(:i18n, :I18n) do
6
+ auth_value_method :i18n_cascade?, true
7
+ auth_value_method :i18n_raise_on_missing_translations?, false
8
+ auth_value_method :i18n_fallback_to_untranslated?, false
9
+ auth_value_method :i18n_options, {}
10
+
11
+ auth_value_methods(
12
+ :i18n_namespace,
13
+ :i18n_available_locales,
14
+ )
15
+
16
+ auth_methods(
17
+ :i18n_locale,
18
+ )
19
+
20
+ @directories = Set.new
21
+
22
+ class << self
23
+ attr_reader :directories
24
+ end
25
+
26
+ def post_configure
27
+ super
28
+ i18n_register File.expand_path("#{__dir__}/../../../locales")
29
+ end
30
+
31
+ def translate(name, default)
32
+ i18n_translate(name, default)
33
+ end
34
+
35
+ def i18n_locale
36
+ ::I18n.locale
37
+ end
38
+
39
+ private
40
+
41
+ def i18n_translate(name, default, **options)
42
+ ::I18n.translate(i18n_translation_key(name),
43
+ scope: i18n_scope,
44
+ locale: i18n_locale,
45
+ raise: i18n_raise_on_missing_translations?,
46
+ default: i18n_default(name, default),
47
+ **i18n_options,
48
+ **options
49
+ )
50
+ end
51
+
52
+ def i18n_translation_key(name)
53
+ [*i18n_namespace, name].join(".")
54
+ end
55
+
56
+ def i18n_default(name, fallback)
57
+ default = []
58
+ default << name if i18n_namespace && i18n_cascade?
59
+ default << fallback if i18n_fallback_to_untranslated? && !i18n_raise_on_missing_translations?
60
+ default
61
+ end
62
+
63
+ def i18n_namespace
64
+ self.class.configuration_name
65
+ end
66
+
67
+ def i18n_register(directory)
68
+ files = i18n_files(directory)
69
+ files.each { |file| i18n_add(file) }
70
+ i18n_reload
71
+ Rodauth::I18n.directories << directory
72
+ end
73
+
74
+ # Returns list of translation files in given directory based on
75
+ # available locales.
76
+ def i18n_files(directory)
77
+ locales = i18n_available_locales
78
+ pattern = locales ? "{#{locales.join(",")}}" : "*"
79
+
80
+ Dir["#{directory}/#{pattern}.yml"]
81
+ end
82
+
83
+ # User-defined translations have most likely already been loaded at this
84
+ # point, so we prepend built-in translations to the load path to ensure we
85
+ # don't override them.
86
+ def i18n_add(file)
87
+ ::I18n.load_path.unshift(file) unless ::I18n.load_path.include?(file)
88
+ end
89
+
90
+ # Ensure we pick up new entries in the load path.
91
+ def i18n_reload
92
+ ::I18n.reload!
93
+ end
94
+
95
+ # Returns available locales if they have been set.
96
+ def i18n_available_locales
97
+ ::I18n.available_locales if ::I18n.available_locales_initialized?
98
+ end
99
+
100
+ def i18n_scope
101
+ "rodauth"
102
+ end
103
+ end
104
+ end
105
+
106
+ require "rodauth/i18n/login_password_requirements_base"
107
+ Rodauth::I18n.include Rodauth::I18n::LoginPasswordRequirementsBase
@@ -20,6 +20,14 @@ module Rodauth
20
20
  i18n_translate(__method__, super) + "#{" (#{password_requirement_message})" if password_requirement_message}"
21
21
  end
22
22
 
23
+ def password_too_long_message
24
+ i18n_translate(__method__, super, password_maximum_length: password_maximum_length)
25
+ end
26
+
27
+ def password_too_many_bytes_message
28
+ i18n_translate(__method__, super, password_maximum_bytes: password_maximum_bytes)
29
+ end
30
+
23
31
  def password_too_short_message
24
32
  i18n_translate(__method__, super, password_minimum_length: password_minimum_length)
25
33
  end
@@ -32,6 +40,10 @@ module Rodauth
32
40
  i18n_translate(__method__, super, login_maximum_length: login_maximum_length)
33
41
  end
34
42
 
43
+ def login_too_many_bytes_message
44
+ i18n_translate(__method__, super, login_maximum_bytes: login_maximum_bytes)
45
+ end
46
+
35
47
  def login_too_short_message
36
48
  i18n_translate(__method__, super, login_minimum_length: login_minimum_length)
37
49
  end
data/locales/en.yml CHANGED
@@ -63,6 +63,7 @@ en:
63
63
  login_notice_flash: You have been logged in
64
64
  login_page_title: Login
65
65
  login_too_long_message: maximum %{login_maximum_length} characters
66
+ login_too_many_bytes_message: maximum %{login_maximum_bytes} bytes
66
67
  login_too_short_message: minimum %{login_minimum_length} characters
67
68
  logins_do_not_match_message: logins do not match
68
69
  logout_button: Logout
@@ -114,6 +115,8 @@ en:
114
115
  password_not_enough_character_groups_message: does not include uppercase letters, lowercase letters, and numbers
115
116
  password_same_as_previous_password_message: same as previous password
116
117
  password_too_many_repeating_characters_message: contains too many of the same character in a row
118
+ password_too_long_message: maximum %{password_maximum_length} characters
119
+ password_too_many_bytes_message: maximum %{password_maximum_bytes} bytes
117
120
  password_too_short_message: minimum %{password_minimum_length} characters
118
121
  passwords_do_not_match_message: passwords do not match
119
122
  recovery_auth_button: Authenticate via Recovery Code
data/locales/hr.yml CHANGED
@@ -21,9 +21,12 @@ hr:
21
21
  login_does_not_meet_requirements_message: neispravna email adresa, ne ispunjava uvjete
22
22
  login_label: Email adresa
23
23
  login_too_long_message: najviše %{login_maximum_length} znakova
24
+ login_too_many_bytes_message: najviše %{login_maximum_bytes} bajtova
24
25
  login_too_short_message: najmanje %{login_minimum_length} znakova
25
26
  password_confirm_label: Potvrda lozinke
26
27
  password_does_not_meet_requirements_message: neispravna lozinka, ne ispunjava uvjete
27
28
  password_label: Lozinka
29
+ password_too_long_message: najviše %{password_maximum_length} znakova
30
+ password_too_many_bytes_message: najviše %{password_maximum_bytes} bajtova
28
31
  password_too_short_message: najmanje %{password_minimum_length} znakova
29
32
  # ...
data/locales/pt.yml ADDED
@@ -0,0 +1,244 @@
1
+ pt:
2
+ rodauth:
3
+ account_expiration_error_flash: Não pode aceder a esta conta, visto que expirou
4
+ active_sessions_error_flash: Esta sessão foi encerrada
5
+ add_recovery_codes_button: Adicionar autenticação por códigos de recuperação
6
+ add_recovery_codes_error_flash: Não foi possível adicionar os códigos de recuperação
7
+ add_recovery_codes_heading: "<h2>Adicionar mais Códigos de Recuperação</h2>"
8
+ add_recovery_codes_page_title: Autenticação por Códigos de Recuperação
9
+ already_an_account_with_this_login_message: já existe uma conta com este login
10
+ attempt_to_create_unverified_account_error_flash: A conta que tentou criar está à espera de verificação
11
+ attempt_to_login_to_unverified_account_error_flash: A conta que tentou aceder está à espera de verificação
12
+ change_login_button: Modificar Login
13
+ change_login_error_flash: Houve um erro a modificar o seu login
14
+ change_login_needs_verification_notice_flash: Foi-lhe enviado por email um link para verificar a sua modificação de login
15
+ change_login_notice_flash: O seu login foi modificado
16
+ change_login_page_title: Modificar Login
17
+ change_password_button: Modificar palavra-passe
18
+ change_password_error_flash: Houve um erro a mudar a sua palavra-passe
19
+ change_password_notice_flash: A sua palavra-passe foi mudada
20
+ change_password_page_title: Mudar palavra-passe
21
+ close_account_button: Fechar conta
22
+ close_account_error_flash: Houve um erro ao fechar a sua conta
23
+ close_account_notice_flash: A sua conta foi fechada
24
+ close_account_page_title: Fechar conta
25
+ confirm_password_button: Confirmar palavra-passe
26
+ confirm_password_error_flash: Houve um erro a confirmar a sua palavra-passe
27
+ confirm_password_link_text: Insira a palavra-passe
28
+ confirm_password_notice_flash: A palavra-passe foi confirmada
29
+ confirm_password_page_title: Confirme a palavra-passe
30
+ contains_null_byte_message: contém um byte nulo
31
+ create_account_button: Criar conta
32
+ create_account_error_flash: Houve um erro ao criar a sua conta
33
+ create_account_link_text: Criar uma nova conta
34
+ create_account_notice_flash: A sua conta foi criada
35
+ create_account_page_title: Criar conta
36
+ email_auth_email_recently_sent_error_flash: Foi-lhe recentemente enviado por email um link para login
37
+ email_auth_email_sent_notice_flash: Foi-lhe enviado um email com um link para fazer login na sua conta
38
+ email_auth_email_subject: Link de Login
39
+ email_auth_error_flash: Houve um erro ao fazer login
40
+ email_auth_page_title: Login
41
+ email_auth_request_button: Enviar Link de Login por Email
42
+ email_auth_request_error_flash: Houve um erro ao requisitar um link de autenticação por email
43
+ email_subject_prefix: ''
44
+ expired_jwt_access_token_message: token de Acesso JWT expirada
45
+ global_logout_label: Encerrar todas as sessões activas?
46
+ input_field_label_suffix: ''
47
+ invalid_jwt_format_error_message: Formato JWT inválido ou claim no Authorization header
48
+ invalid_password_message: palavra-passe inválida
49
+ invalid_recovery_code_error_flash: Erro ao atenticar através do código de recuperação
50
+ invalid_recovery_code_message: Código de recuperação inválido
51
+ json_non_post_error_message: método não-POST usado na API JSON
52
+ json_not_accepted_error_message: Accept Header não suportado. Deve aceitar "application/json" ou um tipo de conteúdo compatível
53
+ jwt_refresh_invalid_token_message: token JWT refresh inválida
54
+ jwt_refresh_without_access_token_message: sem token JWT de acesso disponibilizada durante o refresh
55
+ login_button: Login
56
+ login_confirm_label: Confirmar %{login_label}
57
+ login_does_not_meet_requirements_message: login inválido, não satisfaz os requisitos
58
+ login_error_flash: Houve um erro ao efectuar o login
59
+ login_form_footer_links_heading: <h2 class="rodauth-login-form-footer-links-heading">Outras opções</h2>
60
+ login_label: Login
61
+ login_lockout_error_flash: De momento esta conta está bloqueada e não pode ser acedida
62
+ login_not_valid_email_message: não é um endereço de e-mail
63
+ login_notice_flash: Login efectuado com sucesso
64
+ login_page_title: Login
65
+ login_too_long_message: máximo %{login_maximum_length} caracteres
66
+ login_too_short_message: mínimo %{login_minimum_length} caracteres
67
+ logins_do_not_match_message: logins não coincidem
68
+ logout_button: Encerrar sessão
69
+ logout_notice_flash: A sessão foi encerrada
70
+ logout_page_title: Encerrar sessão
71
+ multi_phase_login_page_title: Login
72
+ need_password_notice_flash: Login reconhecido, por favor insira a sua palavra-passe
73
+ new_password_label: Nova palavra-passe
74
+ no_current_sms_code_error_flash: Sem código SMS para esta conta
75
+ no_matching_email_auth_key_error_flash: 'Houve um erro ao fazer login:: chave de autenticação email inválida'
76
+ no_matching_login_message: sem login correspondente
77
+ no_matching_reset_password_key_error_flash: 'Houve um erro ao recuperar a sua palavra-passe: chave de recuperação inválida ou expirada'
78
+ no_matching_unlock_account_key_error_flash: 'Houve um erro ao desbloquear a sua conta: chave de desbloqueio inválida ou expirada'
79
+ no_matching_verify_account_key_error_flash: 'Houve um erro ao verificar a sua conta: chave de verificação de conta inválida'
80
+ no_matching_verify_login_change_key_error_flash: 'Houve um erro ao verificar a sua modificação de login: chave de verificação para modificação de login inválida'
81
+ non_json_request_error_message: Apenas requests no formato JSON são permitidos
82
+ otp_already_setup_error_flash: Já configurou a autenticação TOTP
83
+ otp_auth_button: Autenticar utilizando TOTP
84
+ otp_auth_error_flash: Erro ao iniciar sessão através de autenticação TOTP
85
+ otp_auth_form_footer: ''
86
+ otp_auth_label: Código de Autenticação
87
+ otp_auth_link_text: Autenticar utilizando TOTP
88
+ otp_auth_page_title: Insira o código de autenticação
89
+ otp_disable_button: Desactivar Autenticação TOTP
90
+ otp_disable_error_flash: Erro ao desactivar a autenticação TOTP
91
+ otp_disable_link_text: Desactivar Autenticação TOTP
92
+ otp_disable_notice_flash: Autenticação TOTP foi desactivada
93
+ otp_disable_page_title: Desactivar Autenticação TOTP
94
+ otp_invalid_auth_code_message: Código de autenticação inválido
95
+ otp_invalid_secret_message: secret inválido
96
+ otp_lockout_error_flash: Código de autenticação TOTP foi bloqueado devido a várias tentativas falhadas
97
+ otp_provisioning_uri_label: URL de Provisioninamento
98
+ otp_secret_label: Secret
99
+ otp_setup_button: Configurar Autenticação TOTP
100
+ otp_setup_error_flash: Erro ao configurar a autenticação TOTP
101
+ otp_setup_link_text: Configurar Autenticação TOTP
102
+ otp_setup_notice_flash: A Autenticação TOTP está configurada
103
+ otp_setup_page_title: Configurar Autenticação TOTP
104
+ password_authentication_required_error_flash: Necessita de confirmar a sua palavra-passe para continuar
105
+ password_changed_email_subject: Palavra-passe modificada
106
+ password_confirm_label: Confirmar %{password_label}
107
+ password_does_not_meet_requirements_message: palavra-passe inválida, não satisfaz os requisitos
108
+ password_expiration_error_flash: A sua palavra-passe expirou e precisa de ser modificada
109
+ password_in_dictionary_message: é uma palavra num dicionário
110
+ password_invalid_pattern_message: inclui uma sequência de caracteres comum
111
+ password_is_one_of_the_most_common_message: é uma das palavras-chave mais comuns
112
+ password_label: Palavra-passe
113
+ password_not_changeable_yet_error_flash: A sua palavra-passe ainda não pode ser mudada
114
+ password_not_enough_character_groups_message: não inclui letras maiúsculas, letras minúsculas e números
115
+ password_same_as_previous_password_message: igual à palavra-passe anterior
116
+ password_too_many_repeating_characters_message: contém muitos caracteres repetidos sucessivamente
117
+ password_too_short_message: mínimo %{password_minimum_length} caracteres
118
+ passwords_do_not_match_message: palavras-chave não coincidem
119
+ recovery_auth_button: Autenticar por Código de Recuperação
120
+ recovery_auth_link_text: Autenticar utilizando Código de Recuperação
121
+ recovery_auth_page_title: Insira o Código de Recuperação
122
+ recovery_codes_added_notice_flash: Foram adicionados mais Códigos de Recuperação
123
+ recovery_codes_label: Código de Recuperação
124
+ recovery_codes_link_text: Ver Códigos de Recuperação de Autenticação
125
+ recovery_codes_page_title: Ver Códigos de Recuperação de Autenticação
126
+ remember_button: Modificar configurações de "Lembrar-me"
127
+ remember_disable_label: Desactivar "Lembrar-me"
128
+ remember_error_flash: Houve um erro ao actualizar a sua configuração de "Lembrar-me"
129
+ remember_forget_label: Esquecer-me
130
+ remember_notice_flash: A sua configuração de "Lembrar-me" foi actualizada
131
+ remember_page_title: Modificar configuração de "Lembrar-me"
132
+ remember_remember_label: Lembrar-me
133
+ require_login_error_flash: Por favor faça login para continuar
134
+ resend_verify_account_page_title: Reenviar Email de Verificação
135
+ reset_password_button: Recuperar palavra-passe
136
+ reset_password_email_recently_sent_error_flash: Foi-lhe enviado recentemente um email com um link para recuperar a sua palavra-passe
137
+ reset_password_email_sent_notice_flash: Foi-lhe enviado um email com um link para recuperar a sua palavra-passe
138
+ reset_password_email_subject: Recuperar palavra-passe
139
+ reset_password_error_flash: Houve um erro ao recuperar a sua palavra-passe
140
+ reset_password_explanatory_text: "<p>Se esqueceu a sua palavra-passe, pode fazer um pedido de recuperação:</p>"
141
+ reset_password_notice_flash: A sua palavra-passe foi recuperada
142
+ reset_password_page_title: Recuperar palavra-passe
143
+ reset_password_request_button: Pedir recuperação da palavra-passe
144
+ reset_password_request_error_flash: Houve um erro ao efectuar o pedido de recuperação de palavra-passe
145
+ reset_password_request_link_text: Esqueceu-se da palavra-passe?
146
+ reset_password_request_page_title: Pedir Recuperação de Palavra-chave
147
+ same_as_current_login_message: igual ao login actual
148
+ same_as_existing_password_message: palavra-passe inválida, igual à palavra-passe actual
149
+ session_expiration_error_flash: Esta sessão expirou, por favor faça login novamente
150
+ single_session_error_flash: Esta sessão foi terminada dado que outra sessão ficou activa
151
+ sms_already_setup_error_flash: Autenticação SMS já foi configurada
152
+ sms_auth_button: Autenticar através de código SMS
153
+ sms_auth_link_text: Autenticar utilizando código SMS
154
+ sms_auth_page_title: Autenticar através de código SMS
155
+ sms_code_label: Código SMS
156
+ sms_confirm_button: Confirme o número para SMS de Backup
157
+ sms_confirm_notice_flash: Autenticação SMS foi configurada
158
+ sms_confirm_page_title: Confirme o número para SMS de Backup
159
+ sms_disable_button: Desactivar Autenticação de Backup por SMS
160
+ sms_disable_error_flash: Erro ao desactivar a autenticação por SMS
161
+ sms_disable_link_text: Desactivar Autenticação por SMS
162
+ sms_disable_notice_flash: Autenticação por SMS foi desactivada
163
+ sms_disable_page_title: Desactivar Autenticação de Backup por SMS
164
+ sms_invalid_code_error_flash: Erro ao autenticar através de código SMS
165
+ sms_invalid_code_message: código SMS inválido
166
+ sms_invalid_confirmation_code_error_flash: Código de confirmação SMS inválido ou desactualizado, deverá configurar a autenticação SMS novamente
167
+ sms_invalid_phone_message: número de telefone para SMS inválido
168
+ sms_lockout_error_flash: Autenticação SMS foi bloqueada
169
+ sms_needs_confirmation_error_flash: Autenticação SMS necessita de confirmação
170
+ sms_not_setup_error_flash: Autenticação SMS ainda não foi configurada
171
+ sms_phone_label: Número de Telefone
172
+ sms_request_button: Enviar código SMS
173
+ sms_request_notice_flash: Código de autenticação SMS enviado
174
+ sms_request_page_title: Enviar código SMS
175
+ sms_setup_button: Configurar número SMS de Backup
176
+ sms_setup_error_flash: Erro ao configurar a autenticação através de SMS
177
+ sms_setup_link_text: Configurar Autenticação SMS de Backup
178
+ sms_setup_page_title: Configurar número SMS de Backup
179
+ two_factor_already_authenticated_error_flash: Já foi autenticado através de multifactor
180
+ two_factor_auth_notice_flash: Foi autenticado através de multifactor
181
+ two_factor_auth_page_title: Autenticar utilizando um factor adicional
182
+ two_factor_disable_button: Remover todos os métodos de Autenticação Multifactor
183
+ two_factor_disable_error_flash: Não foi possível remover todos os métodos de autenticação multifactor
184
+ two_factor_disable_link_text: Remover todos os métodos de Autenticação Multifactor
185
+ two_factor_disable_notice_flash: Todos os métodos de Autenticação Multifactor foram desactivados
186
+ two_factor_disable_page_title: Remover todos os métodos de Autenticação Multifactor
187
+ two_factor_manage_page_title: Gerir Autenticação Multifactor
188
+ two_factor_need_authentication_error_flash: Deverá autenticar-se através de um factor adicional antes de continuar
189
+ two_factor_not_setup_error_flash: Esta conta não foi configurada para autenticação multifactor
190
+ two_factor_remove_heading: "<h2>Remover Autenticação Multifactor</h2>"
191
+ two_factor_setup_heading: "<h2>Configurar Autenticação Multifactor</h2>"
192
+ unlock_account_button: Desbloquear Conta
193
+ unlock_account_email_recently_sent_error_flash: Foi-lhe enviado um email recentemente com um link para desbloquear a conta
194
+ unlock_account_email_subject: Desbloquear Conta
195
+ unlock_account_error_flash: Houve um erro ao desbloquear a sua conta
196
+ unlock_account_explanatory_text: "<p>Esta conta está actualmente bloqueada. Pode desbloquear a conta:</p>"
197
+ unlock_account_notice_flash: A sua conta foi desbloqueada
198
+ unlock_account_page_title: Desbloquear Conta
199
+ unlock_account_request_button: Pedir desbloqueio de conta
200
+ unlock_account_request_explanatory_text: "<p>Esta conta está actualmente bloqueada. Pode fazer um pedido para a conta ser desbloqueada:</p>"
201
+ unlock_account_request_notice_flash: Foi-lhe enviado um email com um link para desbloquear a conta
202
+ unlock_account_request_page_title: Pedir desbloqueio de conta
203
+ unverified_account_message: conta não-verificada, por favor verifique a conta antes de fazer login
204
+ unverified_change_login_error_flash: Por favor verifique esta conta antes de modificar o login
205
+ verify_account_button: Verificar Conta
206
+ verify_account_email_recently_sent_error_flash: Foi-lhe enviado um email recentemente com um link para verificar a sua conta
207
+ verify_account_email_sent_notice_flash: Foi-lhe enviado um email com um link para verificar a sua conta
208
+ verify_account_email_subject: Verificar Conta
209
+ verify_account_error_flash: Não foi possível verificar a conta
210
+ verify_account_notice_flash: A sua conta foi verificada
211
+ verify_account_page_title: Verificar Conta
212
+ verify_account_resend_button: Reenviar email de verificação
213
+ verify_account_resend_error_flash: Não foi possível reenviar o email de verificação de conta
214
+ verify_account_resend_explanatory_text: "<p>Se já não possui o email para verificar a conta, pode pedir que lhe seja reenviado:</p>"
215
+ verify_account_resend_link_text: Reenviar informação de verificação de conta
216
+ verify_login_change_button: Verificar modificação de Login
217
+ verify_login_change_duplicate_account_error_flash: Não foi possível proceder à modificação de login porque já existe uma conta com o novo login
218
+ verify_login_change_email_subject: Verificar modificação de Login
219
+ verify_login_change_error_flash: Não foi possível verificar a modificação de login
220
+ verify_login_change_notice_flash: A sua modificação de login foi verificada
221
+ verify_login_change_page_title: Verificar modificação de Login
222
+ view_recovery_codes_button: Ver códigos de recuperação para autenticação
223
+ view_recovery_codes_error_flash: Não foi possível visualizar os códigos de recuperação
224
+ webauthn_auth_button: Autenticar com WebAuthn
225
+ webauthn_auth_error_flash: Erro ao autenticar com WebAuthn
226
+ webauthn_auth_link_text: Autenticar com WebAuthn
227
+ webauthn_auth_page_title: Autenticar com WebAuthn
228
+ webauthn_duplicate_webauthn_id_message: tentativa de adicionar um id webauthn duplicado
229
+ webauthn_invalid_auth_param_message: parâmetro de autenticação webauthn inválido
230
+ webauthn_invalid_remove_param_message: deve seleccionar um autenticador webauthn válido para remover
231
+ webauthn_invalid_setup_param_message: parâmetro de configuração webauthn inválido
232
+ webauthn_invalid_sign_count_message: credencial webauthn tem um sign count inválido
233
+ webauthn_login_error_flash: Houve um erro a autenticar utilizando WebAuthn
234
+ webauthn_not_setup_error_flash: Esta conta não foi configurada para autenticação WebAuthn
235
+ webauthn_remove_button: Removee Autenticador WebAuthn
236
+ webauthn_remove_error_flash: Erro ao remover autenticador WebAuthn
237
+ webauthn_remove_link_text: Remover autenticador WebAuthn
238
+ webauthn_remove_notice_flash: O autenticador WebAuthn foi removido
239
+ webauthn_remove_page_title: Remover Autenticador WebAuthn
240
+ webauthn_setup_button: Configurar Autenticação WebAuthn
241
+ webauthn_setup_error_flash: Erro ao configurar a autenticação WebAuthn
242
+ webauthn_setup_link_text: Configurar Autenticação WebAuthn
243
+ webauthn_setup_notice_flash: A Autenticação WebAuthn está agora configurada
244
+ webauthn_setup_page_title: Configurar Autenticação WebAuthn
data/rodauth-i18n.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rodauth-i18n"
5
- spec.version = "0.1.0"
5
+ spec.version = "0.3.1"
6
6
  spec.authors = ["Janko Marohnić"]
7
7
  spec.email = ["janko@hey.com"]
8
8
 
@@ -15,13 +15,12 @@ Gem::Specification.new do |spec|
15
15
  spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*", "locales/**/*", "*.gemspec"]
16
16
  spec.require_paths = ["lib"]
17
17
 
18
- spec.add_dependency "rodauth", "~> 2.0"
18
+ spec.add_dependency "rodauth", "~> 2.19"
19
19
  spec.add_dependency "i18n", "~> 1.0"
20
20
 
21
21
  spec.add_development_dependency "minitest"
22
22
  spec.add_development_dependency "minitest-hooks"
23
23
  spec.add_development_dependency "capybara"
24
- spec.add_development_dependency "sqlite3"
25
24
  spec.add_development_dependency "tilt"
26
25
  spec.add_development_dependency "bcrypt"
27
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2022-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rodauth
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: sqlite3
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: tilt
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -129,18 +115,14 @@ executables: []
129
115
  extensions: []
130
116
  extra_rdoc_files: []
131
117
  files:
132
- - CHANGELOG.md
133
118
  - LICENSE.txt
134
119
  - README.md
135
- - lib/generators/rodauth/i18n/translations_generator.rb
136
- - lib/rodauth-i18n.rb
120
+ - lib/generators/rodauth/translations_generator.rb
137
121
  - lib/rodauth/features/i18n.rb
138
- - lib/rodauth/i18n.rb
139
- - lib/rodauth/i18n/feature.rb
140
122
  - lib/rodauth/i18n/login_password_requirements_base.rb
141
- - lib/rodauth/i18n/railtie.rb
142
123
  - locales/en.yml
143
124
  - locales/hr.yml
125
+ - locales/pt.yml
144
126
  - rodauth-i18n.gemspec
145
127
  homepage: https://github.com/janko/rodauth-i18n
146
128
  licenses:
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2021-10-07
4
-
5
- - Initial release
@@ -1,17 +0,0 @@
1
- require "rails/generators/base"
2
-
3
- module Rodauth
4
- module I18n
5
- class TranslationsGenerator < ::Rails::Generators::Base
6
- source_root File.expand_path("#{__dir__}/../../../../locales")
7
-
8
- argument :locales, type: :array, desc: "List of locales to copy translation files for"
9
-
10
- def copy_locales
11
- locales.each do |locale|
12
- copy_file("#{locale}.yml", "config/locales/rodauth.#{locale}.yml")
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,65 +0,0 @@
1
- require "rodauth/i18n/login_password_requirements_base"
2
- require "i18n"
3
-
4
- module Rodauth
5
- Feature.define(:i18n) do
6
- include Rodauth::I18n::LoginPasswordRequirementsBase
7
-
8
- auth_value_method :i18n_cascade?, true
9
- auth_value_method :i18n_raise_on_missing_translations?, false
10
- auth_value_method :i18n_fallback_to_untranslated?, false
11
- auth_value_method :i18n_options, {}
12
-
13
- auth_value_methods(
14
- :i18n_namespace,
15
- )
16
-
17
- auth_methods(
18
- :i18n_locale,
19
- )
20
-
21
- def translate(name, default)
22
- i18n_translate(name, default)
23
- end
24
-
25
- def i18n_locale
26
- ::I18n.locale
27
- end
28
-
29
- private
30
-
31
- def i18n_translate(name, default, **options)
32
- ::I18n.translate(i18n_translation_key(name),
33
- scope: i18n_scope,
34
- locale: i18n_locale,
35
- raise: i18n_raise_on_missing_translations?,
36
- default: i18n_default(name, default),
37
- **i18n_options,
38
- **options
39
- )
40
- end
41
-
42
- def i18n_translation_key(name)
43
- [*i18n_namespace, name].join(".")
44
- end
45
-
46
- def i18n_default(name, fallback)
47
- default = []
48
- default << name if i18n_namespace && i18n_cascade?
49
- default << fallback if i18n_fallback_to_untranslated? && !i18n_raise_on_missing_translations?
50
- default
51
- end
52
-
53
- def i18n_namespace
54
- self.class.configuration_name
55
- end
56
-
57
- def i18n_scope
58
- "rodauth"
59
- end
60
- end
61
-
62
- # Assign feature and feature configuration to constants for introspection.
63
- I18n::Feature = FEATURES[:i18n]
64
- I18n::FeatureConfiguration = FEATURES[:i18n].configuration
65
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails"
4
-
5
- module Rodauth
6
- module I18n
7
- class Railtie < ::Rails::Railtie
8
- initializer "rodauth.i18n" do
9
- Rodauth::I18n.add
10
- end
11
- end
12
- end
13
- end
data/lib/rodauth/i18n.rb DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "i18n"
4
- require "rodauth/i18n/railtie" if defined?(Rails)
5
-
6
- module Rodauth
7
- module I18n
8
- def self.add(locales = nil)
9
- ::I18n.load_path.concat files(locales)
10
- end
11
-
12
- def self.files(locales = nil)
13
- directory_pattern = "{#{directories.join(",")}}"
14
-
15
- if ::I18n.available_locales_initialized?
16
- locales ||= ::I18n.available_locales
17
- file_pattern = "{#{locales.join(",")}}"
18
- else
19
- file_pattern = "*"
20
- end
21
-
22
- Dir["#{directory_pattern}/#{file_pattern}.yml"]
23
- end
24
-
25
- def self.directories
26
- @directories ||= [File.expand_path("#{__dir__}/../../locales")]
27
- end
28
- end
29
- end
data/lib/rodauth-i18n.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rodauth/i18n"