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

Line ending when call @vscode/l10n-dev export #129

Open
Cosifne opened this issue Aug 15, 2023 · 3 comments
Open

Line ending when call @vscode/l10n-dev export #129

Cosifne opened this issue Aug 15, 2023 · 3 comments
Labels
feature-request Request for new features or functionality @vscode/l10n-dev
Milestone

Comments

@Cosifne
Copy link
Member

Cosifne commented Aug 15, 2023

Hi,

We have seen in https://github.com/dotnet/vscode-csharp/blob/main/l10n/bundle.l10n.json, initially everything is end with crlf
But after adding a string and run @vscode/l10n-dev export
git would complain that the line ending is changed to lf
image
Is there any way to use 'crlf' as the line ending?

@TylerLeonhardt
Copy link
Member

I'm using JSON.stringify to turn the bundle object into a string:
https://github.com/microsoft/vscode-l10n/blob/main/l10n-dev/src/cli.ts#L181

it turns out there isn't a way to say "I want the lines to end in CRLF" within JSON.stringify... so the only solution is to do something prettty hacky by post processing. We run the risk of turning actual expected usages of LF's into CLRF's which does concern me.

Alternatives:

Configuring git to allow LF files would workaround this warning:
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

The other question I have is... why check in a file that's entirely generated?

@TylerLeonhardt TylerLeonhardt added feature-request Request for new features or functionality @vscode/l10n-dev labels Aug 15, 2023
@TylerLeonhardt TylerLeonhardt added this to the Backlog milestone Aug 15, 2023
@Cosifne
Copy link
Member Author

Cosifne commented Aug 15, 2023

Hi Tyler,
We run all the localization work in the pipeline so every time the bot performed localization, someone in our team would see this issue. So I start the issue to ask if there is any existing solution for this.

It's not a big problem if it is not configurable now. Thanks for your quick response.

@FALLAI-Denis
Copy link

Hi,

What if add replace("\r(\n)?","\r\n") on result string of JSON.stringify?

writeFileSync(resolvedOutFile, JSON.stringify(jsonResult, undefined, 2).replace("\r(\n)?","\r\n"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality @vscode/l10n-dev
Projects
None yet
Development

No branches or pull requests

3 participants