Skip to content

Conversation

@exterkamp
Copy link
Member

Summary
This fixes 2 issues:

  1. tc/ adds more plural paths for other languages (1, # -expand to-> 1, #, zero, few, two, etc.) and when it does this it copies the placeholders, so multiple placeholders are copied. This change performs a global replace for ICU values to replace all instances of a placeholder.
  2. The pruning script used require which does not reload a file if it is modified in the same process, which is what happens when you collect-strings. So we need to reload it to pick up changes in the lhl from an import. (thanks @patrickhulce)

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM w/ request(s)

for (const localePath of localePaths) {
const absoluteLocalePath = path.join(lhRoot, localePath);
const localeLhl = require(absoluteLocalePath);
const localeLhl = JSON.parse(fs.readFileSync(absoluteLocalePath, 'utf-8'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Change seems fine (and probably for the best, who knows where we'll run pruning from in the future) but just to clarify, where else do we require() the lhl files in collect-strings and how does the error manifest?

Copy link
Collaborator

Choose a reason for hiding this comment

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

could we get the comment in here about why we needed to do this? it certainly wasn't obvious to me debugging that it's run in the same process as collect-strings :)

and the error manifests in the update command being a noop because we use the pre-overriden strings instead of the new ones

Copy link
Contributor

Choose a reason for hiding this comment

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

it certainly wasn't obvious to me debugging that it's run in the same process as collect-strings :)

this may be one of those things that's obvious while writing it but isn't when running it, so we could change it. The idea was that collect-strings collects then creates an updated en-US.json, so it made sense at that point to make sure none of the existing LHL files conflicted with the new en-US.json.

and the error manifests in the update command being a noop because we use the pre-overriden strings instead of the new ones

what action is being done that's a no-op? #9598 definitely removed strings after running collect-strings.js. What else in there is loading the locale json files and overwriting them with the cached version?

Copy link
Collaborator

Choose a reason for hiding this comment

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

what action is being done that's a no-op?

the entire script command that updates the locales from tc becomes a no-op because this function just overwrites them with the locales that were there originally (i.e. it "prunes" the cached copy loaded require which is old)

Copy link
Contributor

Choose a reason for hiding this comment

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

the entire script command that updates the locales from tc becomes a no-op because this function just overwrites them with the locales that were there originally

ah, see @exterkamp, this is why that script should be in this repo :P

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM

for (const localePath of localePaths) {
const absoluteLocalePath = path.join(lhRoot, localePath);
const localeLhl = require(absoluteLocalePath);
const localeLhl = JSON.parse(fs.readFileSync(absoluteLocalePath, 'utf-8'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we get the comment in here about why we needed to do this? it certainly wasn't obvious to me debugging that it's run in the same process as collect-strings :)

and the error manifests in the update command being a noop because we use the pre-overriden strings instead of the new ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants