Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Eclipse Globalization Guidelines"

(Eclipse Globalization Guidelines)
(Eclipse Globalization Guidelines)
Line 20: Line 20:
 
===All ResourceBundle file contents should be encoded in UTF-8===
 
===All ResourceBundle file contents should be encoded in UTF-8===
 
Different operating systems running in different language settings may save files in different encodings. To avoid confusions, we recommend all Eclipse developers and translators to encode all ResourceBundle source file contents and all translated ResourceBundle file contents in UTF-8.
 
Different operating systems running in different language settings may save files in different encodings. To avoid confusions, we recommend all Eclipse developers and translators to encode all ResourceBundle source file contents and all translated ResourceBundle file contents in UTF-8.
 
+
<br />
 +
<br />
 
[[Image:guidelineIndicator.gif]]'''<font color="#09448d">Guideline 1.1</font>'''
 
[[Image:guidelineIndicator.gif]]'''<font color="#09448d">Guideline 1.1</font>'''
 
<blockquote><font color="#09448d">All ResourceBundle source file contents should be encoded in UTF-8.</font></blockquote>
 
<blockquote><font color="#09448d">All ResourceBundle source file contents should be encoded in UTF-8.</font></blockquote>
 +
[[Image:guidelineIndicator.gif]]'''<font color="#09448d">Guideline 2.1</font>'''
 +
<blockquote><font color="#09448d">All translated ResourceBundle file contents should be encoded in UTF-8.</font></blockquote>
 +
===Single Quote Handling===
 +
Depending on whether the code will process the message string through the Java MessageFormat class, single quotes in ResourceBundle files should be written differently. If the string will be processed by MessageFormat, then any single quote in the string must be doubled. Otherwise, a single quote should not be doubled. Translators who do not have access to the code cannot tell if the message string would be processed by MessageFormat.
  
 +
Most Java programmers follow the model of processing the message string with MessageFormat only if the message string contains replacement variables. We recommend all Eclipse developers to follow these guidelines when creating message strings and writing the code to process the message strings:
 +
<li>Strings which contain replacement variables are processed by the MessageFormat class (single quote must be coded as 2 consecutive single quotes &quote&quote).
 +
<li>Strings which do NOT contain replacement variables are NOT processed by the MessageFormat class (single quote must be coded as 1 single quote &quote).
 +
<br />
 +
<br />
 
[[Image:guidelineIndicator.gif]]'''<font color="#09448d">Guideline 1.2</font>'''
 
[[Image:guidelineIndicator.gif]]'''<font color="#09448d">Guideline 1.2</font>'''
<blockquote><font color="#09448d">All translated ResourceBundle file contents should be encoded in UTF-8.</font></blockquote>
+
<blockquote><font color="#09448d">Process message string with Java MessageFormat class only if the message string contains replacement variables.</font></blockquote>
 +
 
 +
Here are examples of messages strings in ResourceBundle file and expected text displayed to end user:
 +
<li>ResourceBundle file:
 +
<br />
 +
<nowiki>
 +
String_1 = No variable.  1 quote (') 2 (''), 3 ('''), 4 ('''').
 +
</nowiki>
 +
<br />
 +
<nowiki>
 +
String_2 = Variable {1}. 2 quotes(''), 4 ('''').
 +
</nowiki>
 +
<li>Text displayed to end user:
 +
<br />
 +
<nowiki>
 +
String_1 => No variable.  1 quote (') 2 (''), 3 ('''), 4 ('''').
 +
</nowiki>
 +
<br />
 +
<nowiki>
 +
String_2 => Variable xxx. 2 quotes('), 4 ('').
 +
</nowiki>
 
[[Category:Eclipse Technology Project]]
 
[[Category:Eclipse Technology Project]]

Revision as of 12:31, 7 January 2008

Eclipse Globalization Guidelines

This document is a working draft.

Kit Lo

Last Updated: January 2008

Note: Please use Babel committers mailing list to add comments instead of embedding them in this document.

Introduction

Eclipse is an open source project contributed by developers around the world. Every developer’s programming style may be a little different. Often times, developers may not aware that little things they do in their programs may have a huge impacts in globalization of Eclipse. In this document, we try to define a set of guidelines for Eclipse globalization. If these guidelines are adopted by all Eclipse developers and translators, it will lead to greater consistency and the success of globalizing Eclipse.

In this section, we will discuss the rationales behind some of the globalization guidelines. At the end of the document, a summary of the Eclipse Globalization Guidelines is listed.

Eclipse Resource Bundle Process

Standard Java resource bundles are not very memory efficient. The keys for a resource bundle are stored in the class files of the plug-in, which are saved somewhere in the JVM’s data structures. The resource bundles are loaded in whole, even when no string is ever looked up from it.

Eclipse came up with an alternate resource bundle process in release 3.1 to improve memory usage. A conversion tool was provided to migrate to the new resource bundle process. See Message Bundle Conversion Tool for more information.

All ResourceBundle file contents should be encoded in UTF-8

Different operating systems running in different language settings may save files in different encodings. To avoid confusions, we recommend all Eclipse developers and translators to encode all ResourceBundle source file contents and all translated ResourceBundle file contents in UTF-8.

GuidelineIndicator.gifGuideline 1.1

All ResourceBundle source file contents should be encoded in UTF-8.

GuidelineIndicator.gifGuideline 2.1

All translated ResourceBundle file contents should be encoded in UTF-8.

Single Quote Handling

Depending on whether the code will process the message string through the Java MessageFormat class, single quotes in ResourceBundle files should be written differently. If the string will be processed by MessageFormat, then any single quote in the string must be doubled. Otherwise, a single quote should not be doubled. Translators who do not have access to the code cannot tell if the message string would be processed by MessageFormat.

Most Java programmers follow the model of processing the message string with MessageFormat only if the message string contains replacement variables. We recommend all Eclipse developers to follow these guidelines when creating message strings and writing the code to process the message strings:

  • Strings which contain replacement variables are processed by the MessageFormat class (single quote must be coded as 2 consecutive single quotes &quote&quote).
  • Strings which do NOT contain replacement variables are NOT processed by the MessageFormat class (single quote must be coded as 1 single quote &quote).

    GuidelineIndicator.gifGuideline 1.2
    Process message string with Java MessageFormat class only if the message string contains replacement variables.

    Here are examples of messages strings in ResourceBundle file and expected text displayed to end user:

  • ResourceBundle file:
    String_1 = No variable. 1 quote (') 2 (''), 3 ('''), 4 ('''').
    String_2 = Variable {1}. 2 quotes(''), 4 ('''').
  • Text displayed to end user:
    String_1 => No variable. 1 quote (') 2 (''), 3 ('''), 4 ('''').
    String_2 => Variable xxx. 2 quotes('), 4 ('').
  • Copyright © Eclipse Foundation, Inc. All Rights Reserved.