How can I create a module for parsing a custom file format?

In my project, I am using TypeScript with localisations nested within classes and objects, meanwhile the available integration doesn’t support anything that doesn’t resemble a simple key-value object. I researched custom modules, I tried to find a guide on how to create one, but I wasn’t able to find anything. I also wasn’t able to find any existing example of a custom file format parser for Crowdin.

An example of what one of such localisations looks like:

class Commands {
	static readonly game = typedLocalisations({
		name: {
			'English': 'game',
			'Polish': 'gra',
			'Romanian': 'joc',
		description: {
			'English': 'Pick the correct word out of four to fit in the blank.',
			'Polish': 'Wybierz słowo, które pasuje do luki w zdaniu.',
			'Romanian': 'Alege cuvântul care se potrivește cu spațiul gol din propoziție.',
		strings: {
			sentence: {
				'English': 'Sentence',
				'Polish': 'Zdanie',
				'Romanian': 'Propoziție',
			translation: {
				'English': 'Translation',
				'Polish': 'Tłumaczenie',
				'Romanian': 'Traducere',
			noSentencesAvailable: {
				'English': 'There are no sentences available in the requested language.',
				'Polish': 'Nie ma zdań dostępnych w tym języku.',
				'Romanian': 'Nu sunt propoziții disponibile în această limbă.',

Many of the localisations’ values are anonymous functions that resolve to strings, and aren’t strings themselves, too.

Any pointers to guides with such parsers would be appreciated.

1 Like

I see that TypeScript is supported by the platform, have you checked it?

1 Like

Try this one

All modules that are not “system” are customs. For the native TS, probably there’s a limitation from tech side, and even with custom modules Crowdin can’t recognize everything.

That being said, I would recommend you to do the small refactoring.

I would recommend doing a small refactoring of your code, moving localization strings to JSON files so you have one file per language.

I would like to assume that you can generate these localization files right from your runtime. Just console.log or fs.write from the object that you currently have.

Then change your code to import localization keys form these JSON files. You can use TS files to store your keys as well.


Only shallow key-value objects are supported.

1 Like