-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…localization, and MessageSourceService - Added IntelliJ IDEA project files for configuration and code styles. - Introduced MessageSourceService class for handling internationalization (i18n). - Included English and Turkish localization files for validation and error messages. - Added `.gitignore` with Java, Maven, Gradle, IntelliJ, and other standard entries. - Configured Maven settings for accessing GitHub repositories.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<servers> | ||
<server> | ||
<id>github</id> | ||
<username>YOUR_GITHUB_USERNAME</username> | ||
<password>YOUR_GITHUB_TOKEN</password> | ||
</server> | ||
</servers> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.github.r4tylmz.betterpoi.i18n; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* Service for handling internationalization (i18n) of messages. | ||
* This class is compatible with Java 1.8 and uses standard Java libraries. | ||
*/ | ||
public class MessageSourceService { | ||
private static final String BUNDLE_NAME = "messages"; | ||
private final ResourceBundle bundle; | ||
|
||
/** | ||
* Creates a new MessageSourceService for the specified locale. | ||
* | ||
* @param locale the locale to use for messages | ||
*/ | ||
public MessageSourceService(Locale locale) { | ||
this.bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale); | ||
} | ||
|
||
/** | ||
* Creates a MessageSourceService using the system default locale. | ||
* | ||
* @return a new MessageSourceService instance | ||
*/ | ||
public static MessageSourceService createDefault() { | ||
return new MessageSourceService(Locale.getDefault()); | ||
} | ||
|
||
/** | ||
* Creates a MessageSourceService for the specified language. | ||
* | ||
* @param language the language code (e.g., "en" for English, "tr" for Turkish) | ||
* @return a new MessageSourceService instance | ||
*/ | ||
public static MessageSourceService forLocale(String language) { | ||
return new MessageSourceService(new Locale(language)); | ||
} | ||
|
||
/** | ||
* Gets a localized message with the given key and formats it with the provided arguments. | ||
* | ||
* @param key the message key in the resource bundle | ||
* @param args the arguments to format the message with | ||
* @return the formatted localized message | ||
*/ | ||
public String getMessage(String key, Object... args) { | ||
String pattern = bundle.getString(key); | ||
return MessageFormat.format(pattern, args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pattern.validation.error=Cell value [{0}] is not valid. Cell value must match with the pattern: {1} | ||
required.validation.error=Header [{0}] is required and cannot be null or empty. | ||
duplicate.row.error=Duplicate row found | ||
header.mismatch.error=Column header mismatch at index {0}. Expected: {1}, Found: {2} | ||
workbook.null.error=workbook can't be null | ||
workbook.class.null.error=WorkBookClass must not be null | ||
sheet.not.found.error=Unable to find sheet with name: {0} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pattern.validation.error=Hücre değeri [{0}] geçerli değil. Hücre değeri şununla eşleşmeli: {1} | ||
required.validation.error=Başlık [{0}] zorunludur ve boş bırakılamaz. | ||
duplicate.row.error=Yinelenen satır bulundu | ||
header.mismatch.error={0} indeksinde sütun başlığı uyuşmazlığı var. Beklenen: {1}, Bulunan: {2} | ||
workbook.null.error=Çalışma kitabı boş olamaz | ||
workbook.class.null.error=Çalışma kitabı sınıfı boş olamaz | ||
sheet.not.found.error=Belirtilen isimde sayfa bulunamadı: {0} |