Closed a2br closed 3 years ago
Besides that, you don't have to care about yarn tsc
, these scripts are not meant to be use by the app. They are used when I'm import / exporting translations via Poeditor, not when the app runs.
I was worrying about that because these are TS files, they need to be compiled to run; since they import stuff from other TS files, I thought all the files would need to be compiled together.
It means that you're trying to run the script as an ES2015 module, but Node.js supports CommonJS. This is a configuration error of TypeScript or whatever compiles its. To use the js import
statements instead of the require
statements, you'll need to add "type": "module"
in package.json
, although I recommend you to manually edit the files. As a reminder, you need to compile TypeScript files before you run them. The error you got may also appear when trying to run a TS file (which isn't supposed to be used).
If that's what happened, you should try tsc ./scripts/poeditor/spread-translation-files.ts
and then the node command. It should work. I can't use the require
statements in my commits because the ESLint CI would block that.
spread-translation-files.ts
didn't need to be in TypeScript, so I changed it to JavaScript. The problem you encountered should be fixed now.
I'll keep working on group-translation-files.ts
to make the same changes tomorrow evening, I'll have to manually import all the JSON files
@a2br still not working at all. I think you don't really understand the task unfortunately. In the first hand, I don't see the generated files that should be comitted with all the translations. Please re-submit if you find a solution.
I have fully understood what you meant. I've been working on them this morning and their are now functional. I'll resolve some path problems and I'll open another PR this evening (with the language JSONs included then).
Note: the currently commited files indeed do not work
Update: nos working. I'll mâle them produce decent JSONs with spaces, lines, etc
Summary
These scripts have been requested in issue https://github.com/NMF-earth/nmf-app/issues/225. There are 2 of them:
group-translation-files.ts
: gets the translations from all the known translation files in the repo to put them all together, sorted by languagespread-translation-files.ts
: reverses the previous script's work. It spreads the data from the reference files (built bygroup-translation-files.ts
) across all the other translation files in known translation directoriesThe reference translation files (ex:
en.json
) will be placed in/scripts/poeditor
, next to the scripts.They have been built to be flexible in case of future changes. For example, adding a new language only requires to add a 2-letters string in an array -- same for the translation dirs.
Notes
They have not been tested. Actually, I don't know how to do it.
tsc
doesn't compile anymore, even after some twists intsconfig.json
... 🤔 As always, let me know if you spot an error.How to run them?
Once compiled using
tsc
, I assume you'd just have to runnode ./path/to/script
. As written above, I haven't tested them though, since the TypeScript Compiler doesn't compile. Tell me if I'm talking nonsense, I'm not familiar with React Native projects nor the way they are executed.