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.
The WrappedString
class is a straightforward utility designed for wrapping String
values. It provides methods for creating, retrieving, and modifying the wrapped string.
WrappedString wrappedString = WrappedString.of("Hello, World!");
System.out.println(wrappedString.toString()); // Output: Hello, World!
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.
// greeting='Hello, ${0}!'
File englishFile = new File("en.properties");
File spanishFile = new File("es.properties");
GlobalTranslations.init(Map.of("0", "MyApp"), englishFile, spanishFile);
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!
This library is licensed under the GPL-3.0 License. Feel free to use, modify, and distribute it as needed.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or create a pull request.
We follow Semantic Versioning. For the available versions, see the releases on this repository.
This library is actively maintained by the IzanagiCraft team. For inquiries, reach out to [email protected].
Copyright (c) 2023 - present | IzanagiCraft team and contributors. See the LICENSE file for details.