-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add gettext support to the android version #10019
Conversation
Implementation of MultiCraft. |
Note that this PR does not automatically detect the android language. |
What for? JNI can detect language, just read the documentation. |
As stated in the binary part of the PR, I used gettext, as it's already the translation engine for minetest. I also considered https://github.com/tinygettext/tinygettext and https://github.com/j-jorge/libintl-lite, but since the |
That was the purpose of my comment, you have to add a JNI call to get the current locale. |
Thanks, I'm not a full time android developer and most of the time, I only play with the java side and almost never touch the NDK. |
exec { | ||
commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a comment that indicates that gradle will not be able to do this on Windows at all, as well as on macOS without brew install gettext
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Is there a place to add this note ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfan5 your suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows can do that as long msgfmt
is within the path. All it needs is a comment stating that this section requires gettext
to be installed and available in PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see if I can add a test and break early with a meaningful error message.
I added automatic locale detection if it's not set in the UI or minetest.conf |
1b25d44
to
40476c0
Compare
Rebased on latest master after 5.3.0 release |
I don't have an Android setup, but the code looks good. 👍 if someone else can confirm this as working. |
@@ -202,7 +207,12 @@ void init_gettext(const char *path, const std::string &configured_language, | |||
#endif // ifndef _WIN32 | |||
} | |||
else { | |||
#ifdef __ANDROID__ | |||
char lang[3] = {0}; | |||
/* set current system default locale */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this before #ifdef
@@ -59,6 +59,11 @@ include $(PREBUILT_STATIC_LIBRARY) | |||
#LOCAL_SRC_FILES := deps/Android/OpenSSL/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcrypto.a | |||
#include $(PREBUILT_STATIC_LIBRARY) | |||
|
|||
include $(CLEAR_VARS) | |||
LOCAL_MODULE := GetText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just gettext
as here https://www.gnu.org/software/gettext/
I can confirm that this completely works and has been using MultiCraft for a while. |
I'll take time this week to address the few comments, I've left this pending for too much time |
@rubenwardy this really can be merged. Tested and used in my fork |
I can confirm that this PR works, too. |
Is there a reason this hasn't been merged yet? |
@oleastre Are you still work in it? |
@Pevernow I did not updated it for a while, even locally. |
Rebased/continued in #11435 |
Add compact, short information about your PR for easier understanding:
Goal of the PR
Add gettext and internationalization support in the android version
How does the PR work?
Add dependency on a static version of gettext, and add mo files to the packaged android assets.
Depends on Add gettext libraries minetest_android_deps_binaries#3
Does it resolve any reported issue?
Solves Android does not support gettext translations #6093
To do
This PR is Ready for Review.
How to test
Build and launch an android client, set the language to something not english in the settings, restart and enjoy a translated mintest.