Flix01 / imgui

Dear ImGui Addons Branch = plain unmodified dear imgui plus some extra addon.
https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Home
MIT License
396 stars 34 forks source link

datechooser localization #59

Closed newk5 closed 3 years ago

newk5 commented 3 years ago

Would it be possible to allow the user to specify the month names and day names? This would be useful when the application is using a language other than english.

Flix01 commented 3 years ago

I think, as far as I can remember, that if you set your locale to your country locale, then months and day names should already be in your country language.

In fact, if you compile the the first demo (for the desktop), this should be the default behavior (see main.cpp).

Basically if you add to your program these lines, then it should work:

#include <locale.h>

// in your main function:
setlocale(LC_TIME, "");         // This affects imguidatechooser (the language of the names of the months)

At least this works for me.

newk5 commented 3 years ago

Oh I see, but if I want to set it to language different than my operating system, is this possible? Is there a locale I can apply for each country? Sorry I'm not a c++ developer, I'm using the datechooser from the imgui java bindings: https://github.com/ice1000/jimgui

If this is possible, then the java bindings would need to be adjusted to allow setting up a locale from java and have that applied in C++

Flix01 commented 3 years ago

Is there a locale I can apply for each country?

Well, you can change the locale to the one of another country, if you want:

setlocale(LC_TIME, "ja_JP.utf8"); // // date and time formatting will be Japanese

I'm using the datechooser from the imgui java bindings: https://github.com/ice1000/jimgui

I know nothing about it, so I can't help with java.

What you would like to do exactly?

newk5 commented 3 years ago

Ah ok, thanks that's all I needed to know. I just needed to know if there was a way so I can talk with the person maintaining the java bindings to make this a possibility from the java side since the java bindings have a port for your datechooser.

Flix01 commented 3 years ago

OK. In case the maintainer needs further info about it, these links might be helpful: https://en.cppreference.com/w/c/locale/setlocale https://stackoverflow.com/questions/12170488/how-to-get-current-locale-of-my-environment (the post with the green check mark)

ice1000 commented 3 years ago

Thank you all!