Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not localizable #185

Open
d-musique opened this issue Jun 29, 2024 · 7 comments
Open

Not localizable #185

d-musique opened this issue Jun 29, 2024 · 7 comments

Comments

@d-musique
Copy link

Hello. This package is impossible to localize as it is into other languages.

One may attempt to redefine the strings in a custom header and wrap these into gettext() calls.
There is an obstacle: the code relies on these strings being defined as literals, and build fails.

Besides, it would be more helpful if texts were already wrapped in _("text") fashion; then the translation tools can readily scan these strings, making the task a lot simpler.

@aiekick
Copy link
Owner

aiekick commented Jun 29, 2024

Hello,

what do you mean by "as it is into other languages" ?

you have a Config file where you can redefine all literals to that form _("text") if you want.

that not an issue.

@d-musique
Copy link
Author

Look here for instance.

if (IMGUI_BUTTON(okButtonString "##validationdialog", ImVec2(okButtonWidth, 0.0f)) || m_FileDialogInternal.isOk) {

Given that this code uses preprocessor-based string concatenation, replacing it with a dynamic expression fails.
This scheme occurs multiple times.

I'm not sure, but maybe these ID concatenations could be replaced by PushID() / PopID() pairs.

@aiekick
Copy link
Owner

aiekick commented Jun 29, 2024

maybe you need one config file per localisation, because you will have the same issue for many other ImGui based lib.

theses funcs uses const char* event if i remove this "##tag" you will have the issue..

but what is your localisation system ? what language / framework ?

@d-musique
Copy link
Author

My file ImGuiFileDialogCustomConfig.h is similiar to this

#include "Utility/I18n.h"

#define createDirButtonString "+"
#define okButtonString _("OK")
#define cancelButtonString _("Cancel")
[...]

and the macro _ is defined to gettext.
Gettext goes read the translated string from a file on disk and returns it as a char*.

In fact, I can affirm that rewriting that "##tag" concatenation in a compatible way will fix the problem.
But the edited code I have in my tree is kinda unclean for now, I can remake it into a clean PR later.

@aiekick
Copy link
Owner

aiekick commented Jun 29, 2024

you localization system seem to be a performance killer.
Are you sure you understand how ImGui is working ?

you system seem ok with many classic gui like QT, who is not call these _() each time. but for ImGui its crazy...

So you need to be smarter and pre calc the most of things for a fast display..
like have a class with many const char*, but a call to _() at each frames ???

@d-musique
Copy link
Author

There isn't slowness. Texts will always be cached after the first access.
It's just implementation detail anyway. This is how state-of-the-art i18n works.

@aiekick
Copy link
Owner

aiekick commented Jun 29, 2024

LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants