Skip to content
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

CLDR-17850 Show when patterns allow different widths or not #3997

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

e-ikwut
Copy link
Contributor

@e-ikwut e-ikwut commented Aug 28, 2024

CLDR-17850

  • This PR completes the ticket.

ALLOW_MANY_COMMITS=true

@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@@ -169,6 +171,7 @@ public class ExampleGenerator {
private static final Date DATE_SAMPLE2;
private static final Date DATE_SAMPLE3;
private static final Date DATE_SAMPLE4;
private static final Date DATE_SAMPLE5;
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 redundant with CLDR-15698 #3895, which is ready for merge

break;
}
} else {
altPatternBuilder.append(item);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, if item is not a VariableField, it's a literal string. The ticket description mentions using fp.toString(i, i + 1). Is this acceptable in its place?

Copy link
Member

Choose a reason for hiding this comment

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

You want to leave the literals completely alone. So the above looks good.

+ "\"]";
String forcedAltValue = cldrFile.getWinningValue(altXpath);
String unforcedAltValue = generateAltPattern(value);
String forcePrefix = forcedAltValue != null ? "" : EXAMPLE_OF_INCORRECT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally, I had the condition as forcedAltValue.equals(unforcedAltValue)
That didn't work (forcedAltValue was sometimes null), so I tried this instead. Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it does make sense, I realize I've flipped the condition (forcing would be when the value is not null, not when the value is null)

However, I'm very dubious of this, since it's not what we discussed. As written, it seems like forcedAltValue is always null.

+ "']/timeSeparator");
dfs = sdf.getDateFormatSymbols();
dfs.setTimeSeparatorString(timeSeparator);
sdf.setDateFormatSymbols(dfs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copy-pasted this chunk from above. The only change is icuServiceBuilder.getDateFormat(calendar, unforcedAltValue, numbersOverride); instead of icuServiceBuilder.getDateFormat(calendar, value, numbersOverride); Is there a way to just change the pattern on a SimpleDateFormat instead of creating a new one?

Copy link
Member

Choose a reason for hiding this comment

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

You could pull that chunk of code out into a function, and call with slightly different parameters. Better that code copying (which is harder to maintain).


example = addExampleResult(forcePrefix + sdf.format(DATE_SAMPLE) + ", " + sdf.format(DATE_SAMPLE5), example, showContexts);
}
return example;
Copy link
Contributor Author

@e-ikwut e-ikwut Aug 28, 2024

Choose a reason for hiding this comment

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

Should I account for the details checked below, i.e., show context if value does not contain "MMM" or "LLL" ?

@@ -2411,6 +2418,36 @@ private String handleTimeZoneName(XPathParts parts, String value) {
return result;
}

private String generateAltPattern(String dateTimeValue) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rereading the ticket, I see "the caller can specify the width of various fields." Right now, I'm only accounting for different widths of hours (I thought, at first, that only hours were relevant). Should I be checking every variable field? In that case, couldn't the number of possible examples be very high (e.g. if all of h,m,s can have their width changed, would 8 examples be desired)?

Copy link
Member

Choose a reason for hiding this comment

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

For time, we only allow the first to be padded or not, eg:

9:08:07 or 09:08:07, but not 9:8:7

Copy link
Member

Choose a reason for hiding this comment

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

Add comment that this function could be generalizes for fields other than h/H. (If you had more time, you could do it, but the hourglass has run out....)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants