remram44 / pybabel-godot

Plugin for Babel to support Godot scene files (.tscn)
Other
14 stars 11 forks source link

Add basic supports for csharp files, and fix an issue on my end #3

Closed westtunger closed 3 years ago

westtunger commented 3 years ago

This commit adds basic support for csharp file, as Godot supports them and we needed to be able to extract translatable texts from them. This will only find and get strings that are inside a TranslationServer.Translate() call.

Also, fix an issue I had where unwanted \r caused the extraction of texts from tscn files to fail, even though the regex should not take them. (I'm on windows 10, could that be the cause ?)

remram44 commented 3 years ago

I think Babel can handle C-Sharp files by default quite well, so I don't think we need to add regexes in here? If you use -k Translate for example, does it not work?

westtunger commented 3 years ago

I think Babel can handle C-Sharp files by default quite well, so I don't think we need to add regexes in here? If you use -k Translate for example, does it not work?

Can it? I couldn't get Pybabel to work with all the cs files... That's why I went with a simple custom solution.

I get a 'tokenize.TokenError: ('EOF in multi-line statement', (376, 0))' when running it on some of them, using the python extractor.

I tried using the javascript extractor, and it does indeed seems to properly extract csharp, my bad. I switched from using string to using keywords as keys as well in the .tscn, which fixed the other issue too. So I'll close this pr.

Sorry for bothering you 😃

remram44 commented 3 years ago

Not at all! I'm glad you found this useful!