Changes

Update to 1.19
Line 35: Line 35:  
{{Tip/Important|A common issue is having the server localize for clients. The server can only localize in its own locale, which does not necessarily match the locale of connected clients.
 
{{Tip/Important|A common issue is having the server localize for clients. The server can only localize in its own locale, which does not necessarily match the locale of connected clients.
 
<br/><br/>
 
<br/><br/>
To respect the language settings of clients, the server should have clients localize text in their own locale using <code>TranslatableComponent</code> or other methods preserving the language neutral translation keys.}}
+
To respect the language settings of clients, the server should have clients localize text in their own locale using components with <code>TranslatableContents</code> or other methods preserving the language neutral translation keys.}}
    
<h3 id="I18n"><tt style="font-size: 100%">net.minecraft.client.resources.language.I18n</tt></h3>
 
<h3 id="I18n"><tt style="font-size: 100%">net.minecraft.client.resources.language.I18n</tt></h3>
Line 43: Line 43:  
<code>get(String, Object...)</code> localizes in the client’s locale with formatting. The first parameter is a translation key, and the rest are formatting arguments for <code>String.format(String, Object...)</code>.
 
<code>get(String, Object...)</code> localizes in the client’s locale with formatting. The first parameter is a translation key, and the rest are formatting arguments for <code>String.format(String, Object...)</code>.
   −
=== <tt style="font-size: 100%">TranslatableComponent</tt> ===
+
=== <tt style="font-size: 100%">TranslatableContents</tt> ===
   −
<code>TranslatableComponent</code> is a <code>Component</code> that is localized and formatted lazily. It is very useful when sending messages to players because it will be automatically localized in their own locale.
+
<code>TranslatableContents</code> is a <code>ComponentContents</code> that is localized and formatted lazily. A <code>Component</code> can be created for this using <code>Component#translatable</code>. It is very useful when sending messages to players because it will be automatically localized in their own locale.
   −
The first parameter of the <code>TranslatableComponent(String, Object...)</code> constructor is a translation key, and the rest are used for formatting. The only supported format specifiers are <code>%s</code> and <code>%1$s</code>, <code>%2$s</code>, <code>%3$s</code> etc. Formatting arguments may be other <code>Component</code>s that will be inserted into the resulting formatted text with all their attributes preserved.
+
The first parameter of the <code>TranslatableContents(String, Object...)</code> constructor is a translation key, and the rest are used for formatting. The only supported format specifiers are <code>%s</code> and <code>%1$s</code>, <code>%2$s</code>, <code>%3$s</code> etc. Formatting arguments may be other <code>Component</code>s that will be inserted into the resulting formatted text with all their attributes preserved.
       
[[Category:Common Concepts]]
 
[[Category:Common Concepts]]