Skip to content

Commit

Permalink
feat: add initial project setup with IntelliJ configuration, message …
Browse files Browse the repository at this point in the history
…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
r4tylmz committed Dec 20, 2024
1 parent 7600f3e commit e407d11
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/settings.xml
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>
88 changes: 88 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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);
}
}
7 changes: 7 additions & 0 deletions src/main/resources/messages.properties
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}
7 changes: 7 additions & 0 deletions src/main/resources/messages_tr.properties
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}

0 comments on commit e407d11

Please sign in to comment.