godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.06k stars 21.12k forks source link

.cs is not an option in POT generation files #84203

Open wdhtcsjh opened 11 months ago

wdhtcsjh commented 11 months ago

Godot version

4.1.2-stable

System information

Godot v4.1.2.stable.mono - Arch Linux #1 SMP PREEMPT_DYNAMIC Thu, 26 Oct 2023 00:52:20 +0000 - Tty - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 Ti (nvidia; 535.113.01) - Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz (8 Threads)

Issue description

Currently cannot add cs files to pot generation.

Steps to reproduce

Go to Project Settings, Select Localization in the Settings Screen. Click on POT Generation in the subscreen. Click on Add. Go to the bottom right drop down and click to show the options and .cs does not exist.

Minimal reproduction project

Can do this with a new project.

AnidemDex commented 11 months ago

.cs is used for CSharp scripts, isn't it?

According docs, Godot uses .po or .mo

Edit: My commentary was not relevant for this issue, thank you for the clarification :sweat_smile:

akien-mga commented 11 months ago

@AnidemDex The POT generation feature is something that parses the project scenes and scripts to extract strings and generate a POT file. The POT file is then use to generate PO files for translation.

Here the problem is AFAIR simply that there is no builtin translation string extraction plugin for C# scripts, so the feature is not supported yet for such scripts.

AdriaandeJongh commented 10 months ago

The ability to scan C# .cs files for POT generation is really a core missing feature when it comes to Godot's otherwise well integrated translation system. Perhaps the lack of this feature should be mentioned clearly in the documentation. And while I'm talking about the documentation, all code examples about translation are GDScript only, which maybe makes sense considering no POT Generation support for C#?

Calinou commented 10 months ago

See https://github.com/godotengine/godot-proposals/issues/8555#issuecomment-1856948582.

HKunogi commented 2 days ago

One idea that may be worth is the way POEdit does for code files, it allows you to define what function is called for translations, so lets say you have a 'Localization.GetString(string key)', then it would search on source files for places calling this specific function and take the actual key argument you passing on the call to this function, adding it as key on the POT. Godot does have few functions like Tr() and TranslationServer.Translate() which could be used as search points on C# code and wherever its found, then get the arguments passed to add on the POT file (and maybe additionally allow the user to define custom functions to search for as well). It can be done either by simply scanning the .cs file as text or for more advanced tracking, would need to build it (without AOT) and use reflection on the built library to scrap for references (would be way more precise and could even track variables being passed, but its way more complex to be done).