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

Internationalizing Carcassonne.jar #10

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Conversation

mitsugu
Copy link

@mitsugu mitsugu commented Feb 21, 2024

#9
For now, I have decided to forego internationalizing error messages and thrown strings, which are rarely encountered by typical application users.
I thought the error message should be made known to developers and contributors, and it would be better if it remained as the original string.
So I'm internationalizing the menus, major dialog boxes, and tooltip strings and adding Japanese locales in addition to English.
Please let me know if you have any undesirable coding or better ideas.

@tsaglam tsaglam linked an issue Feb 22, 2024 that may be closed by this pull request
@tsaglam
Copy link
Owner

tsaglam commented Feb 22, 2024

I would agree with you that error and exception messages should probably stay in English.
I will try to find time for a proper review once your PR is ready. For now, I noticed that you use initialization methods and thus make final fields/constants non-final. I would prefer to keep them final and initialize them in the constructor or just directly in the case of constants. Also, right now, the PR adds a lot of resource classes (LoadText...), and I was wondering If we really need one per class. I think I would prefer one Messages class per package, e.g. like this:

public class Messages {
    private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$

    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

    private Messages() {
    }

    public static String getString(String key) {
        try {
            return RESOURCE_BUNDLE.getString(key);
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }
}

For the keys, more descriptive names are better.
Regarding naming conventions, I try to avoid abbreviations in identifiers and rather use full names.

@mitsugu
Copy link
Author

mitsugu commented Feb 23, 2024

Actually, this is my first time writing Java code. Looking at your code, I am acutely aware of how little I know about the Java language, Java packages, or object-oriented programming.
I saw the Messages class you wrote and thought it was simple and beautiful. I would like to try implementing internationalization again using this class.
However, I have some health issues at the moment, so I need some time to finish the work. Therefore, you may want to wait a little while, or you may be able to complete the internationalization first.

@tsaglam
Copy link
Owner

tsaglam commented Feb 23, 2024

No worries, we are not in a hurry, since this is just a hobby project. Maybe I will find time to do the foundation for internationalization. I will keep you posted.

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

Successfully merging this pull request may close these issues.

About internationalization
2 participants