-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional I18n APIs. #12
base: master
Are you sure you want to change the base?
Changes from 10 commits
8e04a2b
53cafc1
fa53d42
23ffa83
d3da46c
451a038
ad1fab8
b7b0a28
5d1e035
27e29b3
0b8ae14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,9 @@ | |
|
||
package fr.zcraft.zlib.components.gui; | ||
|
||
import fr.zcraft.zlib.components.i18n.I; | ||
import fr.zcraft.zlib.components.i18n.I18n; | ||
import fr.zcraft.zlib.components.i18n.LazyTranslation; | ||
import fr.zcraft.zlib.core.ZLib; | ||
import java.util.Locale; | ||
import org.bukkit.entity.Player; | ||
|
@@ -164,6 +166,25 @@ void setParent(GuiBase parent) | |
/** @return The locale used by the player this Gui instance is associated to. */ | ||
protected final Locale getPlayerLocale() { return playerLocale; } | ||
|
||
/** | ||
* Sends a message to the player this Gui instance is associated to. | ||
* @param message The message to send to the player. | ||
*/ | ||
protected void sendMessage(String message) | ||
{ | ||
getPlayer().sendMessage(message); | ||
} | ||
|
||
/** | ||
* Sends a message to the player this Gui instance is associated to. | ||
* @param message The message to send to the player. | ||
* @param parameters Parameters for the translatable format text, if any. | ||
*/ | ||
protected void sendMessage(LazyTranslation message, Object... parameters) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sans demander un retrait, quelle utilité à |
||
{ | ||
sendMessage(I.t(message, parameters)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pas de traduction automatique ici vu que la locale du joueur, pourtant accessible, n'est pas passée ? |
||
} | ||
|
||
protected boolean checkImmune() | ||
{ | ||
if(!immune) return false; | ||
|
@@ -176,6 +197,4 @@ private void setImmune(boolean immune) | |
this.immune = immune; | ||
} | ||
|
||
/* ===== Static API ===== */ | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,16 @@ public static String t(String text, Object... parameters) | |
{ | ||
return I18n.translate(null, null, text, null, null, parameters); | ||
} | ||
|
||
public static String t(Locale locale, LazyTranslation text, Object... parameters) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Il serait préférable d'avoir un autre nom de méthode, afin que Par exemple |
||
{ | ||
return I18n.translate(locale, text, parameters); | ||
} | ||
|
||
public static String t(LazyTranslation text, Object... parameters) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Même remarque que pour l'autre pour le nom. Le nom peut également être |
||
{ | ||
return t(null, text, parameters); | ||
} | ||
|
||
/** | ||
* Translates the string with a plural. | ||
|
@@ -304,5 +314,19 @@ public static void sendTcn(Player player, String context, String singular, Strin | |
{ | ||
player.sendMessage(I18n.translate(I18n.getPlayerLocale(player), context, singular, plural, count, parameters)); | ||
} | ||
|
||
public static LazyTranslation l(String messageId) | ||
{ | ||
return l(messageId, null, null, null); | ||
} | ||
|
||
public static LazyTranslation l(String messageId, String pluralMessageId, Integer count) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. À renommer pour que (J. Neper serait content.) |
||
{ | ||
return l(messageId, pluralMessageId, count, null); | ||
} | ||
|
||
public static LazyTranslation l(String messageId, String pluralMessageId, Integer count, String context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. À renommer pour que Aussi dans les autres méthodes ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Il manque une méthode |
||
{ | ||
return new LazyTranslation(messageId, pluralMessageId, count, context); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L'autre qui retire des espaces