Skip to content

A Simple Message Translation and Placeholder replacement lib.

License

Notifications You must be signed in to change notification settings

IzanagiCraft/message-format

Repository files navigation

logo

IzanagiCraft - Message Format Library

Support

Overview

The Message Format Library is a Java library designed to facilitate message formatting and translation in Java applications. It provides a set of classes, including WrappedString, GlobalTranslations, and StaticMessagePlaceholders, to assist in handling and formatting messages efficiently.


TODO: add implementation


WrappedString

The WrappedString class is a straightforward utility designed for wrapping String values. It provides methods for creating, retrieving, and modifying the wrapped string.

Example Usage:

WrappedString wrappedString = WrappedString.of("Hello, World!");
System.out.println(wrappedString.toString()); // Output: Hello, World!

GlobalTranslations

The GlobalTranslations class manages translations for different locales using a map of Properties objects. It supports the initialization of translations, default replacements, and provides methods for translating messages.

Example Initialization:

// greeting='Hello, ${0}!'
File englishFile = new File("en.properties");
File spanishFile = new File("es.properties");

GlobalTranslations.init(Map.of("0", "MyApp"), englishFile, spanishFile);

Example Translation:

String translatedMessage = GlobalTranslations.translate(Locale.EN, "greeting");
System.out.println(translatedMessage); // Output: Hello, MyApp!

// with added object placeholers
String translatedMessage = GlobalTranslations.translate(Locale.EN, "greeting", "John");
System.out.println(translatedMessage); // Output: Hello, John!

TODO: StaticMessagePlaceholders formatting description


License

This library is licensed under the GPL-3.0 License. Feel free to use, modify, and distribute it as needed.

Contribution

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or create a pull request.

Versioning

We follow Semantic Versioning. For the available versions, see the releases on this repository.


Authorship

This library is actively maintained by the IzanagiCraft team. For inquiries, reach out to contact@izanagicraft.com.

Copyright

Copyright (c) 2023 - present | IzanagiCraft team and contributors. See the LICENSE file for details.