-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathLocalisationUtils.java
More file actions
53 lines (48 loc) · 2.68 KB
/
LocalisationUtils.java
File metadata and controls
53 lines (48 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package gregtech.api.util;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
public class LocalisationUtils {
/**
* @deprecated
* This function calls `net.minecraft.client.resources.I18n.format` when called on client
* or `net.minecraft.util.text.translation.I18n.translateToLocalFormatted` when called on server.
* <ul>
* <li>It is intended that translations should be done using `I18n` on the client.</li>
* <li>For setting up translations on the server you should use `TextComponentTranslatable`.</li>
* <li>`LocalisationUtils` is only for cases where some kind of translation is required on the server and there is no client/player in context.</li>
* <li>`LocalisationUtils` is "best effort" and will probably only work properly with en-us.</li>
* </ul>
* @param localisationKey the localisation key passed to the underlying format function
* @param substitutions the substitutions passed to the underlying format function
* @return the localized string.
*/
@Deprecated
public static String format(String localisationKey, Object... substitutions) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted(localisationKey, substitutions);
} else {
return net.minecraft.client.resources.I18n.format(localisationKey, substitutions);
}
}
/**
* @deprecated
* This function calls `net.minecraft.client.resources.I18n.hasKey` when called on client
* or `net.minecraft.util.text.translation.I18n.canTranslate` when called on server.
* <ul>
* <li>It is intended that translations should be done using `I18n` on the client.</li>
* <li>For setting up translations on the server you should use `TextComponentTranslatable`.</li>
* <li>`LocalisationUtils` is only for cases where some kind of translation is required on the server and there is no client/player in context.</li>
* <li>`LocalisationUtils` is "best effort" and will probably only work properly with en-us.</li>
* </ul>
* @param localisationKey the localisation key passed to the underlying hasKey function
* @return a boolean indicating if the given localisation key has localisations
*/
@Deprecated
public static boolean hasKey(String localisationKey) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
return net.minecraft.util.text.translation.I18n.canTranslate(localisationKey);
} else {
return net.minecraft.client.resources.I18n.hasKey(localisationKey);
}
}
}