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
CSV formatter #188
CSV formatter #188
Conversation
The CSV formatter can only handle one language per file. Fields are formatted as `key,value,comment`.
Previously forced quotes so `strip` could be run on each section to remove newlines. Changed from `strip` to a RegExp that removes only lines that are completely empty. Quotes no longer mandatory.
Thank you very much for your work! At a first glance it looks very good, I'll take a closer look on the weekend 👍 |
Great, thanks! |
Interesting. Thank you for this! I am curious, though. I would imagine that people using Thus, how useful is this current implementation? And if we decide to add multiple languages later, would that break anyone who decided to start using this one? |
@scelis, yeah I'm starting to lean towards multi-language CSVs too. I went for single language because it is I need in my particular use case, but I can easily see how multi-language would make a lot more sense. Just to make sure we consider all options, two other solutions could be
I'll update the PR for whatever we decide on. |
I don't think we need an extra flag or an extra formatter. What do you think about using the existing
|
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.
Short and concise 👍 I only added two comments/questions.
|
||
def format_section(section, lang) | ||
# removes empty lines | ||
super.gsub(/^$\n/, '') |
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.
If it's important to not have empty lines in the CSV, we should add a unit test for this
|
||
def read(io, lang) | ||
while line = io.gets | ||
fields = ::CSV.parse_line(line) |
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.
doesn't this also add the header as translation?
In general I like the idea of having a CSV formatter a lot. It's been requested multiple times. However I also think it should be a multi-language formatter. By default it should output all languages if the @Bogidon do you want to give the implementation a go? (Sorry again for taking ages to react :-/) |
Also sorry for leaving this up in the air for so long (my I18N project at worked got temporarily shelved). I'll definitely have a go on it, hopefully in the next few days. |
Closing due to inactivity. Please reopen if you ever have time to revisit! |
Yet Another Try at adding a CSV formatter (related: #34, #41, #154).
I went for a barebones formatter, opting out of creating a convention for encoding multiple languages in one CSV file. The format is similar to Apple's
.strings
except that language information is encoded in the file name:strings-en.csv
strings-ro.csv
Here's some sample CSV, pulled out from the test fixtures:
I was a little confused about where exactly I should be adding tests. Just let me know what I should fix and I'll jump on it!