Skip to content

Commit

Permalink
Fix whitesapces in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendelski committed Jan 4, 2023
1 parent 5405d19 commit 790c51c
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ I18nMessagePack messagePack=I18nMessagePack.builder()
.build();

// ...when request arrives
I18nMessages messages=messagePack.localize(req.getLocale());
print(messages.getMessage("greeting",userName));
I18nMessages messages = messagePack.localize(req.getLocale());
print(messages.getMessage("greeting", userName));
```

## Message formatting
Expand Down Expand Up @@ -78,20 +78,20 @@ Messages can be created in 3 ways:

```java
I18nMessagePack messages=I18nMessagePack.builder()
.addMessage(Loacles.EN_US,"hello","Hello {0}")
.addMessage(Loacles.PL_PL,"hello","Cześć {0}")
.addMessage(Loacles.EN_US, "hello", "Hello {0}")
.addMessage(Loacles.PL_PL, "hello", "Cześć {0}")
.setDefaultLocale(PL_PL)
.build();

messages.getMessage(Loacles.EN_US,"hello",userName);
messages.getMessage(Loacles.EN_US, "hello", userName);
```

If you want to quickly load messages from a nested map (for example fetched from a document storage)
you can use `I18nParsers.parseEntries(map, locale)` to translate nested the map keys into localized message paths.

```java
I18nMessagePack messages=I18nMessagePack.builder()
.addMessages(I18nParsers.parseEntries(Map.of("hello","Hello {0}"),EN_US))
.addMessages(I18nParsers.parseEntries(Map.of("hello", "Hello {0}"), EN_US))
.build();
```

Expand Down Expand Up @@ -131,7 +131,7 @@ There is [dev mode](#devmode) that auto-reloads files during development.

To reload messages in file change use:

```
```java
I18nMessagePack.builder()
.scanFileSystem("i18n/*")
.buildAndWatchForChanges();
Expand All @@ -152,7 +152,7 @@ I18nMessagePack messages=I18nMessagePack.builder()
.addFallbackKeyPrefix("glossary")
.build();

String message=messages.getMessage(Locales.en_US,"hello");
String message=messages.getMessage(Locales.en_US, "hello");
```

Locations used to find the message:
Expand All @@ -173,7 +173,7 @@ I18nMessagePack messages=I18nMessagePack.builder()
.addMessageFallbackKeyPrefix("common")
.build();

String message=messages.getMessage(Locales.en_US,"hello");
String message = messages.getMessage(Locales.en_US, "hello");
```

Locations used to find the message:
Expand All @@ -194,9 +194,10 @@ I18nMessagePack messages=I18nMessagePack.builder()
.scanClassPath("/i18n/messages-{locale}.yml")
.setDefaultLocale(PL_PL)
.build();
I18nMessagePack homepageMessages=messages.prefixQueries("pages.homepage");
String homepageTitle=homepageMessages.getMessage(en_US,"title");
String homepageSubtitle=homepageMessages.getMessage(en_US,"title");

I18nMessagePack homepageMessages = messages.prefixQueries("pages.homepage");
String homepageTitle = homepageMessages.getMessage(en_US, "title");
String homepageSubtitle = homepageMessages.getMessage(en_US, "title");
```

Locations used to find the message:
Expand All @@ -219,9 +220,9 @@ I18nMessagePack messagePack=I18nMessagePack.builder()
.build();

// ...when request arrives
I18nMessages messages=messagePack.localize(req.getLocale());
String title=messages.getMessage("title");
String subtitle=messages.getMessage("subtitle");
I18nMessages messages = messagePack.localize(req.getLocale());
String title = messages.getMessage("title");
String subtitle = messages.getMessage("subtitle");
```

Query localization mechanism can be used together with query prefixes:
Expand All @@ -246,7 +247,7 @@ about-company: "${company.name} was established on ${company.established}"
```
```java
messages.getMessage("about-company")=="ACME was established on 1988"
messages.getMessage("about-company") == "ACME was established on 1988"
```

- It's not a part of ICU standard
Expand All @@ -264,7 +265,7 @@ Let's configure messages:

```java
I18nMessagePack messagePack=I18nMessagePack.builder()
.addMessage(EN_US,"msg","${company.name} was established on 1988")
.addMessage(EN_US, "msg", "${company.name} was established on 1988")
.scanClassPath("/i18n/messages-{locale}.yml")
.setDefaultLocale(PL_PL)
.addFallbackKeyPrefix("fallback")
Expand Down Expand Up @@ -331,7 +332,7 @@ messages.getMessage("msg", new Foo(123.456)) == "00123.45600"

When message is missing, exception is thrown. This mechanism can be changed with:

```
```java
// add custom missing message handler
i18nMessagePackBuilder.setMissingMessageHandler(customHandler);

Expand Down Expand Up @@ -421,7 +422,7 @@ This mechanism is disabled by default and can be enabled with: `i18nMessagePackB

You can use file watching capabilities to speed up the development cycle:

```
```java
I18nMessagePackBuidler messagesBuilder = I18nMessagePack.builder()
.setDefaultLocale(EN_US);
// ... other common settings
Expand Down

0 comments on commit 790c51c

Please sign in to comment.