-
Notifications
You must be signed in to change notification settings - Fork 166
Add tests to check for matching HTML tags across locales #8847
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
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -214,8 +214,7 @@ es: | |||||
| help_html: Si no realizó este cambio, %{disavowal_link_html}. Para más ayuda, | ||||||
| visite el %{app_name_html} %{help_link_html} o el %{contact_link_html}. | ||||||
| info_html: '<p>Su cuenta %{app_name} acaba de iniciar sesión en un nuevo | ||||||
| dispositivo.</p><br/><br/> | ||||||
| <p><strong>%{date}<br/>%{location}</strong></p>' | ||||||
| dispositivo.</p><br/><p><strong>%{date}<br/>%{location}</strong></p>' | ||||||
| subject: Nuevo initio de sesion con su %{app_name} cuenta | ||||||
| password_changed: | ||||||
| disavowal_link: restablecer su contraseña | ||||||
|
|
@@ -256,11 +255,12 @@ es: | |||||
| %{app_name}</a></strong> y asegúrese de reconocer toda la información en | ||||||
| la página de su cuenta, incluidos los métodos que utiliza para la | ||||||
| autenticación de dos factores, como el número de teléfono, la aplicación | ||||||
| de autenticación, o la clave de seguridad.</li><li><strong>En la página | ||||||
| de su cuenta %{app_name}, solicite una nueva clave personal.</strong> | ||||||
| Recuerde, nunca lo comparta a menos que lo esté utilizando para iniciar | ||||||
| sesión en un sitio web de confianza que utiliza | ||||||
| %{app_name}.</li></ol></p><br>Gracias,<br>El equipo de %{app_name} | ||||||
| de autenticación, o la clave de seguridad.</li><li><strong>En <a | ||||||
| href="%{account_url}">la página de su cuenta %{app_name}</a>, solicite | ||||||
|
Comment on lines
+258
to
+259
Contributor
Author
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. English version has a third link "your Login.gov account page", which was not reflected in the other locales: identity-idp/config/locales/user_mailer/en.yml Lines 242 to 243 in 0f21a2a
Contributor
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. this is a good candidate for one translation string that should be broken into 2-3 and we should move the markup into the template IMO
Contributor
Author
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. Yeah, the email templates in general could use a lot of love 😬 Not going to try to tackle that here. |
||||||
| una nueva clave personal.</strong> Recuerde, nunca lo comparta a menos | ||||||
| que lo esté utilizando para iniciar sesión en un sitio web de confianza | ||||||
| que utiliza %{app_name}.</li></ol></p><br>Gracias,<br>El equipo de | ||||||
| %{app_name} | ||||||
| intro: Clave personal utilizada para iniciar sesión | ||||||
| subject: Alerta de seguridad de cuenta | ||||||
| phone_added: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -107,6 +107,18 @@ def allowed_untranslated_key?(locale, key) | |||||||||||||
| expect(missing_interpolation_argument_keys).to be_empty | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| it 'has matching HTML tags' do | ||||||||||||||
| i18n.data[i18n.base_locale].select_keys do |key, _node| | ||||||||||||||
| if key.start_with?('i18n.transliterate.rule.') || i18n.t(key).is_a?(Array) || i18n.t(key).nil? | ||||||||||||||
| next | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| html_unique_tags = i18n.locales.map { |locale| i18n.t(key, locale)&.scan(/<.+?>/) }.uniq | ||||||||||||||
|
|
||||||||||||||
| expect(html_unique_tags.size).to eq(1), "HTML tag mismatch for key #{key}" | ||||||||||||||
|
Comment on lines
+116
to
+118
Contributor
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. maybe we can change the structure of this or the message to indicate what the tags are?
Suggested change
Contributor
Author
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. Yeah, I actually added that locally to help troubleshoot the existing issues, so probably good to include something similar, though hopefully moving forward it should be obvious enough to the person adding the new locale strings that there might be a problem with their tags. As proposed, it wasn't especially helpful to debugging some of the more gnarly strings like the one you mentioned, since there's so many tags that it's hard to parse and make use of the output.
Contributor
Author
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. Since I happen to have the history in my terminal, here's what it ended up looking like for that one 🙈 (this was before I
Contributor
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. ah I see your point. I guess it's fine as-is and having the key name is enough to debug |
||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| root_dir = File.expand_path(File.join(File.dirname(__FILE__), '../')) | ||||||||||||||
|
|
||||||||||||||
| Dir[File.join(root_dir, '/config/locales/**')].sort.each do |group_path| | ||||||||||||||
|
|
||||||||||||||
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.
wow yikes glad we're making this linter