Swift: Parse .strings file to .csv file using Command Line Tool - swift

I need to convert my Localizable.strings file to .csv file.
Can i do it using SwiftGen API? What it the best solution for that?

This question could probably use a bit of clarification, Birdy. For example: how often do you need to do this and do you need to do this automatically (as part of building a project) or manually & only occasionally.
Anyways, to answer, the SwiftGen documentation on top of it's repo says nothing about CSV formats, so that's not going to help you.
.strings files are in the format of key=value, so you could simply open the .strings file in your favorite text editor (e.g. Xcode!) and you could use find/replace to replace "=" with a tab character. There's also a couple other solutions found in this very related question.

I faced with the same problem and all the tools I tried did not work. Some for example most tools/technics did not take in to account the comments from the developer that are included in the strings file.
So I ended up developing my own tool csv2strings, that converts Apple's strings file to and from csv files.
Just downloaded it and run:
swift run csv2strings Localizable2.strings

Related

Where does VSCode store its Most Recently Used (MRU) list of .NET projects and solutions on Windows?

Where does VSCode store its Most Recently Used (MRU) list of .NET projects and solutions on Windows?
And also is there some open source code to fetch VSCode's MRUs?
I scanned all files in this dir (recursive) C:\Users\pat\AppData\Roaming\Code with no luck
For you it should be in C:\Users\pat\AppData\Roaming\Code\User\globalStorage\state.vscdb; this file is an SQLite database and you can look around for tools that open this kind of file (because it won't be readable as plain text) to see what's inside and decide whether you can sync it across machines (if that's what you're after).
Also reference this answer, there's very useful stuff over there.
Edit: Thanks this is indeed the file I was looking for.
It can be read with the tool SQLitebrowser.
I didn't easily found a .NET library to read the state.vscdb file + we are very reluctant in embedding a whole library in our product for a small feature.
Hopefully state.vscdb contains the MRU file list in clear textual JSON.
So what I did is just open this file as text, and locate the JSON and read it. Clearly it is ugly but JSON shouldn't be crypted anytime soon in such file and if it fails one day, this feature is not critical for us, just a convenient helper for the user.
The JSON to locate looks like:
{"entries":[
{"fileUri":"file:///c%3A/Dir/treeItem.ts"},
{"fileUri":"file:///c%3A/Dir/YourSolution.sln"},
...

Corrupt Word docx (OpenXML) fixed by Libreoffice - how to identify possible root cause?

I am trying to identify the root cause of a corrupted Microsoft Word docx, the file being the result of a PDF conversion using commercial software. When trying to open this doc in MS Word, I get an error message saying nothing specific, only that the file is corrupted and cannot be opened.
Now, the same file opens fine in Libreoffice. When saving the file as docx from within Libreoffice, I am also able open it in Word again. There are quite a few differences in the contents of the XML files in the unzipped docx file (checked with a diff tool) compared to the one created by Libreoffice. However, I am not sure which ones exactly would cause the file create by Libreoffice to be uncorrupted.
Also, if I unzip the docx and rezip it again, it also opens fine in Word afterwards. I checked the two files on the binary level using a Hexeditor and there were quite a few differences, but it is rather hard or even impossible to understand what these differences mean.
Has anyone has a similar situation and might be able to shed some light on this? I am not sure where to start. Tks.
Problem was solved by doing a roundtrip conversion using the Apache POI library (poi.apache.org)

How to modify a CSV file in Xcode Project Navigator

I'm currently working with a team that updates different rows and columns of a CSV file that lives locally in the app. The issue is that they have resorted to copying and pasting the entire CSV file into a new CSV file, modifying data and copying the edited CSV file and pasting it back into the project. I was curious if anyone had any suggestions on how they can edit the CSV file in Xcode without the complicated mess of copying and pasting.
P.S. Quick Look would prove useful if you could edit the CSV file in this mode.
One simple approach could be to have a reference to the file instead of a hard copy, this way each time you edit the file it should update on the project automatically. Look at this link for more refs: http://www.thomashanning.com/xcode-groups-folder-references/
This answer will only work if you have software such as Microsoft Excel on your computer.
In the Project Navigator, right click the csv file and select open with external editor. This will allow for Xcode to open the csv file using Excel. Modify any data as needed and save your work on Excel. Your csv file in Xcode will now reflect your changes made in Excel.

Is it possible to create pdf file by naming it as .pdf in eclipse?

I am using SVN via eclipse. Now I have to commit a pdf file and I am wondering if I can make it by making a file and naming it as XXX.pdf. I usually have made txt files in this way, but I am not sure if pdf files can work in this way too?
I appreciate your answer. Thanks in advance.
No. It doesn't work that way.

Scratch: How do I produce an ascii text program listing?

My nine year old son is applying to participate in a programming contest. Any language is allowed, and he wants to use Scratch. But the application requires an ascii text listing of a program to solve a specified preliminary problem. They will not accept a PNG screenshot, or Scratch's binary format. So how does he get an ascii listing of his program? If it is impossible (as I suspect) then I will just read his program and retype it into an ascii editor.
You have a few options here.
If you're using Scratch 1.4, you can save a text-only project summary. Shift-click the File menu, then Write project Summary.
This functionality is coming soon (hopefully) to Scratch 2.0. UPDATE: It has been added.
You can also get a text-based representation of all the blocks using the Scratchblocks generator.
Or, you can save the 2.0 project as myproject.sb2, rename to myproject.zip, unpack the ZIP, and take the project.json file.
Unfortunately, none of these methods can easily be imported back into Scratch.
http://scratchblocks.github.io will convert your project into scratchblocks format. It is exactly what you are looking for.
You can download and edit the json script for the Scratch project. It can then be uploaded to replace the existing project. (This is also a great way to back-up and deploy projects)
From the "See Inside" screen, File->Download to your computer.
Rename the file to have a ".zip" extension instead of just ".sb2".
Unzip the file to edit the "project.json" file.
Edit the json code as desired.
Reassemble the zip file
Remove the ".zip" extension. (Back to ".sb2")
Update the Scratch project by going to the original project and selecting File->Upload from your computer.