-
Couldn't load subscription status.
- Fork 1.4k
[LiveLogger ] Localize strings #8682
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
[LiveLogger ] Localize strings #8682
Conversation
Rework some areas to enable localization.
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.
Looks good! And I appreciate all the comments on the new strings.
| { | ||
| public override string ToString() | ||
| { | ||
| string duration = Stopwatch.Elapsed.TotalSeconds.ToString("F1"); |
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.
nit:
We're currently displaying hundredths of a second in the not-live logger, but it seems like we switched to tenths of a second for the live logger. Was that an intentional choice?
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.
It is consistent in new LiveLogger, so I believe it is intentional. IMO, from practical point, tenths are just enough.
| return string.IsNullOrEmpty(TargetFramework) | ||
| ? $"{Indentation}{Project} {Target} ({Stopwatch.Elapsed.TotalSeconds:F1}s)" | ||
| : $"{Indentation}{Project} [{TargetFramework}] {Target} ({Stopwatch.Elapsed.TotalSeconds:F1}s)"; | ||
| ? ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectBuilding_NoTF", |
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.
I was thinking about ways we could combine these into one ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword call...I'm tempted to propose rearranging the arguments to put TF at the end, so we can always pass it even if it's null or empty but not necessarily display it or even having a custom part in the middle of the string, but I'm not convinced either change is actually better.
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.
I though about that. I even have it coded as subpart but the code, IMO, was harder to read and translation was more confusing. It can be changed easily though, if we decide to do so.
| </comment> | ||
| </data> | ||
| <data name="ProjectFinished_NoTF" xml:space="preserve"> | ||
| <value>{0}{1} {2} ({3}s)</value> |
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.
| <value>{0}{1} {2} ({3}s)</value> | |
| <value>{0}Building {1} {2} ({3}s)</value> |
? (If so, then also below)
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.
Intent of this PR was to make Live Logger localizable while keeping it exactly like it was.
If changes in strings are needed I'd rather do it in separate PR.
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.
Looks great! A couple of questions inline.
| <data name="ProjectFinished_NoTF" xml:space="preserve"> | ||
| <value>{0}{1} {2} ({3}s)</value> | ||
| <comment> | ||
| Project finished summary. | ||
| {0}: indentation - few spaces to visually indent row | ||
| {1}: project name | ||
| {2}: BuildResult_{X} | ||
| {3}: duration in seconds with 1 decimal point | ||
| </comment> | ||
| </data> | ||
| <data name="ProjectFinished_WithTF" xml:space="preserve"> | ||
| <value>{0}{1} [2] {3} ({4}s)</value> | ||
| <comment> | ||
| Project finished summary including target framework information. | ||
| {0}: indentation - few spaces to visually indent row | ||
| {1}: project name | ||
| {2}: target framework | ||
| {3}: BuildResult_{X} | ||
| {4}: duration in seconds with 1 decimal point | ||
| </comment> | ||
| </data> | ||
| <data name="ProjectFinished_OutputPath" xml:space="preserve"> | ||
| <value> → {0}</value> | ||
| <comment> | ||
| Info about project output - when known. Printed after ProjectFinished_NoTF or ProjectFinished_WithTF. | ||
| {0}: VT100 coded hyperlink to project output directory | ||
| </comment> | ||
| </data> | ||
| <data name="ProjectBuilding_NoTF" xml:space="preserve"> | ||
| <value>{0}{1} {2} ({3}s)</value> | ||
| <comment> | ||
| Project finished summary. | ||
| {0}: indentation - few spaces to visually indent row | ||
| {1}: project name | ||
| {2}: target | ||
| {3}: duration in seconds with 1 decimal point | ||
| </comment> | ||
| </data> | ||
| <data name="ProjectBuilding_WithTF" xml:space="preserve"> | ||
| <value>{0}{1} [2] {3} ({4}s)</value> | ||
| <comment> | ||
| Project finished summary including target framework information. | ||
| {0}: indentation - few spaces to visually indent row | ||
| {1}: project name | ||
| {2}: target framework | ||
| {3}: target | ||
| {4}: duration in seconds with 1 decimal point | ||
| </comment> | ||
| </data> |
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.
Do you think there's a chance non-English versions of these strings will look differently other than the seconds unit abbreviation? I wonder if we can have only one localized string {0}s and use it for all these.
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.
Do you think there's a chance non-English versions of these strings will look differently
I see it not likely.
However, I am not expert in localization. It could be that theoretically some languages might not use spaces, other languages might despise brackets, some languages prefer different order of data presenting so they can prefer target before of project like target of project.
I'd rather play safe here...
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.
The changes you're describing don't look like something that would be done as part of translation. Maybe there are RTL considerations, not sure. Not blocking but I'd like to ask our loc champion. @richaverma1 can you please provide guidance?
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.
I have checked in past and none supported languages in MSBuild is, AFAIK, RTL.
| { | ||
| public override string ToString() | ||
| { | ||
| string duration = Stopwatch.Elapsed.TotalSeconds.ToString("F1"); |
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.
Is the double -> string formatting locale-aware if done in code like this? My suggestion is to omit the ToString call here and change the placeholder in Strings.resx to something like {0:F1}.
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.
Yes double.ToString does respect Thread.CurrentThread.CurrentCulture - I have also tested it.
Have though about if formatting rules belongs to resx. In this case I proffered it in application logic as I viewed presented decimal point precision as UX design responsibility which do not, IMO, belongs to translation team.
If we choose to change it in future, such change would not trigger need for translation.
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.
Thank you. I guess I could argue either way - for the app logic to own the formatting so it's easier to change in the future and for the resource files to contain it so it can be localized. FWIW, we already have a precedence where the format is specified in .resx and it's translated to the same format in all languages. So it probably doesn't matter.
msbuild/src/Build/Resources/Strings.resx
Line 1481 in c6e6cd4
| <value>{0}{1,-3}{2}: {3:0.000}s {4:0.000}s {5} ({6}) </value> |
|
I recommend to merge it as is - in order to limit future merge conflicts in area of code which will likely have some changes. |
The double-bracing around this was missed in dotnet#8682.
The double-bracing around this was missed in #8682.
Partly Fixes #8391
Context
Ensure all new strings used in the logger are localizable
Changes Made
write(part1); write(part2); write(part3)intostr = formastringfromresources(); write(str)Testing
local
unit tests
Notes