Skip to content

Update translations again#1531

Merged
zachmargolis merged 3 commits intomasterfrom
margolis-update-fr-again
Jul 11, 2017
Merged

Update translations again#1531
zachmargolis merged 3 commits intomasterfrom
margolis-update-fr-again

Conversation

@zachmargolis
Copy link
Contributor

A few notes:

  1. our vendor is giving us poorly formed XML so I patched the converter script to accept this

  2. to try to keep things consitent, I ran i18n-tasks normalize after importing strings, which created a lot of noise in our en.yml and fr.yml files --- sorry for the diff noise but hopefully this should minimize noise in future PRs

@zachmargolis
Copy link
Contributor Author

Update: I fixed some missing keys, I also removed the commit where I used Nokogiri to clean up the incoming XML, we got better results from our vendor.

@zachmargolis
Copy link
Contributor Author

Also pushed another commit renaming an i18n key to be friendlier for future translation exports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this introduced a bunch of additional spaces before the end quote. I see several instances where this happened in this PR. Was that intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for replacing the > convention with quoted strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact of i18n-tasks normalize and our use of the > when wrapping lines. The newlines were already there, this is just making them more explicit:

require 'yaml'
=> true
YAML.load <<-STR
key:
   key: >
     some string
     that we wrap
   other: thing
STR
=> {"key"=>{"key"=>"some string that we wrap\n", "other"=>"thing"}}

I can make a pass and run String#strip on all our keys to remove these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n-tasks normalize uses YAML.dump which almost never wraps lines and just uses string quotes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way for i18n-tasks normalize to ignore wrapping with >? Do we prefer > or string quotes? If string quotes, I would vote to strip them because it looks weird and messy. I like the cleanliness of > and being able to wrap at a comfortable reading line length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so I have a compromise!

It turns out naive YAML.dump on my machine outputs wraps lines at around 100c by default, without quotes if it can.

I made a script that strips whitespace on YAML files in-place and dumps them back, which has the default line wrapping of 100c.

Then I added a lint spec that makes sure the files are formatted to match this, so hopefully this can help keep our files consistent moving forward?

@zachmargolis zachmargolis force-pushed the margolis-update-fr-again branch from a46700c to c546098 Compare July 7, 2017 20:18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a space after the colon because there is more text to the right of it that is dynamically displayed by the password strength JS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This space after the colon was probably automatically stripped, but it's required in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll update the scripts to use chomp to remove newlines instead of all whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL at 0426f5e8e341e8bc84c11e84f8352b8d1462e13e

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with the missing space after the colon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .new is causing the tests to fail because strip_each is a class method.

Copy link
Contributor

@monfresh monfresh Jul 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/#strip_each/.strip_each
# is for instance methods, . is for class methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a result of me flip-flopping on instance vs class, I'll fix it, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include usage instructions in the README?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that the note in the i18n_spec.rb spec description for failures that points to the script is close enough? I don't want the README to get too noisy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this script is meant to be run every time we receive new translations, I think it would be better to give it more visibility, whether in a Wiki or some other place where developers are likely to look up translation-related documentation. What do you think? At the very least, the example in the spec should mention that the command needs a path passed after it. Running scripts/normalize-yaml by itself doesn't do anything. Also, I'm assuming you can give the script a directory, and it will normalize all the files in the directory, but when I tried scripts/normalize-yaml config/locales, it gave me an error. How do you pass in a directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script needs to be run every time we touch translations files (such as when adding new keys to make sure they're alphabetized and wrapped consitently)

To run multiple files, I run:

git ls-files -- config/locales | xargs ./scripts/normalize-yaml

I'll update our translations page in the wiki with this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Approved!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this introduced an extra single quote in n''aurez

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another extra unnecessary single quote here

@monfresh
Copy link
Contributor

Looks like your 4th commit introduced a trailing whitespace in many places that don't need it, as well as unnecessary extra single quotes in words that already have a quote in them.

@zachmargolis
Copy link
Contributor Author

Re: "unnecessary" single quotes, they parse out to the correct thing, are you OK with leaving them in?

YAML.load <<-STR
footnote: 'Vous n''aurez jamais à payer quoi que ce soit avec nous, ni à partager
  le solde de vos comptes. Nous vérifions uniquement le numéro du compte pour
  vérifier votre identité. '
STR
=> {"footnote"=>"Vous n'aurez jamais à payer quoi que ce soit avec nous, ni à partager le solde de vos comptes. Nous vérifions uniquement le numéro du compte pour vérifier votre identité. "}

@monfresh
Copy link
Contributor

I personally think it looks weird. Can we revert that change and manually add the extra space in those 3 places that need it?

@zachmargolis
Copy link
Contributor Author

@monfresh which change? There have been so many changes. Do you mean revert the normalization part, or just the #chomp part? Should I add code that special-cases the : suffix and preserves that whitespace?

@zachmargolis zachmargolis force-pushed the margolis-update-fr-again branch from 92960cf to aae7cd8 Compare July 11, 2017 18:31
Copy link
Contributor

@monfresh monfresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zachmargolis zachmargolis force-pushed the margolis-update-fr-again branch from aae7cd8 to a97bddd Compare July 11, 2017 18:54
**Why**: Better copy

**How**: Also run i18n-tasks normalize to make things consistent
**Why**:
When we ship translations off to vendors, "2fa" gets turned into the
XML tag <2fa> which an invalid tag indentifier, so changing this
makes for a friendlier translation pipeline.
**Why**:
Makes sure we have consistent formatting, naive YAML.dump
adds line wrapping around 100c

Also, add special exception for ': ' when trimming whitespace
@zachmargolis zachmargolis merged commit 2a952e6 into master Jul 11, 2017
@zachmargolis zachmargolis deleted the margolis-update-fr-again branch July 11, 2017 19:34
aduth added a commit that referenced this pull request Jan 22, 2024
We've since moved away from vendor which received string content as XML

Originally: #1531
aduth added a commit that referenced this pull request Jan 23, 2024
* Reimplement password strength as ViewComponent, custom element

changelog: Internal, Code Quality, Improve maintainability of password strength UI element

* Use score directly in class and strength strings

Avoid mappings

See: #9826 (comment)

* Remove XML-safe check from i18n_spec

We've since moved away from vendor which received string content as XML

Originally: #1531

* Update specs for PasswordConfirmationComponent

* Add specs for PasswordStrengthElement

* Arrange conditions in consistent order

Easier comparison

See: https://github.com/18F/identity-idp/pull/9826/files#r1443220055

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>

* Add PasswordStrengthComponent specs

* Add PasswordStrengthComponent component preview

* Update PasswordToggleComponent to respect custom field ID

* Add test coverage for event disavowal password change JavaScript

---------

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants