Skip to content

Commit

Permalink
Adjust localization formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Oct 16, 2023
1 parent 547a67c commit d1b25c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,25 @@ public static void loadBundle(final String bundleName, final Class<?> clazz) {
registerAll(
registry,
availableLocales(bundleName, clazz),
bundleName
bundleName,
false
);

GlobalTranslator.translator().addSource(registry);
}

private static void registerAll(final TranslationRegistry registry, final Set<Locale> locales, final String bundleName) {
private static void registerAll(final TranslationRegistry registry, final Set<Locale> locales, final String bundleName, final boolean escapeSingleQuotes) {
for (final Locale locale : locales) {
final ResourceBundle bundle = PropertyResourceBundle.getBundle(bundleName, locale, UTF8ResourceBundleControl.get());
for (final String key : bundle.keySet()) {
try {
registry.register(
formatKey(bundleName, key),
locale,
new MessageFormat(TranslationRegistry.SINGLE_QUOTE_PATTERN.matcher(bundle.getString(key)).replaceAll("''"))
new MessageFormat(
escapeSingleQuotes ? TranslationRegistry.SINGLE_QUOTE_PATTERN.matcher(bundle.getString(key)).replaceAll("''") : bundle.getString(key),
locale
)
);
} catch (final IllegalArgumentException | MissingResourceException | ClassCastException ex) {
LOGGER.warn("Failed to load translation for key '{}' from bundle '{}' with the '{}' locale.", key, bundleName, locale.getDisplayName(), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ help.showing_results_for_query=Showing search results for query
help.no_results_for_query=No results for query
help.available_commands=Available Commands
help.click_to_show_help=Click to show help for this command
help.page_out_of_range=Error: Page {0} is not in range. Must be in range [1, {1}]
help.page_out_of_range=Error\: Page {0} is not in range. Must be in range [1, {1}]
help.click_for_next_page=Click for next page
help.click_for_previous_page=Click for previous page

Expand All @@ -48,21 +48,21 @@ command.ping_all.description=Displays the pings of connected players with an ave
command.memory.description=Displays the current memory pools of the server JVM. Output will vary greatly based on garbage collection settings.

# Command exceptions
command.exception.invalid_argument=Invalid command argument: {0}
command.exception.invalid_syntax=Invalid command syntax. Correct command syntax is: {0}
command.exception.invalid_argument=Invalid command argument\: {0}
command.exception.invalid_syntax=Invalid command syntax. Correct command syntax is\: {0}
command.exception.invalid_sender_type=Invalid command sender. You must be of type {0}.
command.exception.no_permission=I'm sorry, but you do not have permission to perform this command.\nPlease contact the server administrators if you believe that this is in error.
command.exception.no_permission=I''m sorry, but you do not have permission to perform this command.\nPlease contact the server administrators if you believe that this is in error.
command.exception.command_execution=An internal error occurred while attempting to perform this command.

# Command feedback text
misc.command.text.no_players_found=No players found for selector: '{0}'
misc.command.text.no_players_found=No players found for selector\: ''{0}''
command.ping.text.player_pings=Player Pings
command.ping.text.console_must_provide_player=Console must provide a player to check the ping of.
command.ping.text.average_ping=Average ping
command.ping.text.amount_players={0} players
command.ping.text.amount_players_singular={0} player
command.ping_self.text.your_ping=Your ping: {0}
command.ping_target.text.targets_ping={0}'s ping: {1}
command.ping_self.text.your_ping=Your ping\: {0}
command.ping_target.text.targets_ping={0}''s ping\: {1}
command.memory.text.header=Memory Usage
command.tickinfo.text.mspt_hover=Milliseconds per tick. Avg. MSPT ≤ 50 -> 20 TPS
command.tickinfo.text.tps_hover=Ticks per second. 20 is optimal.
Expand All @@ -77,9 +77,9 @@ command.toggle.actionbar.enabled=Enabled action bar display.
command.toggle.actionbar.disabled=Disabled action bar display.

# Command argument parse failure messages
command.caption.argument.parse.failure.number='{0}' is not a valid number in the range [{1}, {2}].
command.caption.argument.parse.failure.string='{0}' is not a valid string of type {1}.
command.caption.argument.parse.failure.selector.malformed=Selector '{0}' is malformed.
command.caption.argument.parse.failure.number=''{0}'' is not a valid number in the range [{1}, {2}].
command.caption.argument.parse.failure.string=''{0}'' is not a valid string of type {1}.
command.caption.argument.parse.failure.selector.malformed=Selector ''{0}'' is malformed.
command.caption.argument.parse.failure.selector.non_player_in_player_selector=Non-player(s) selected in player selector.

# Misc
Expand Down

0 comments on commit d1b25c9

Please sign in to comment.