# GWT Localized Strings

Under the path `src/gwt/src/org` are files matching `*_en.properties` containing English strings
for the user interface and files matching `*_fr.properties` containing French translations of
those strings.

## Properties File Categories

The `.properties` files are in three categories.

### (1) Generated Files

The following Java classes and their associated `*_en.properties` files are generated and must
not be edited directly. The matching `*_fr.properties` files are not generated and must be
manually updated.

- `src/gwt/src/org/rstudio/studio/client/workbench/prefs/model/UserPrefsAccessorConstants.java`
- `src/org/rstudio/studio/client/workbench/prefs/model/UserStateAccessorConstants.java`
- `src/gwt/src/org/rstudio/studio/client/workbench/commands/MenuConstants.java`
- `src/gwt/src/org/rstudio/studio/client/workbench/commands/CmdConstants.java`

### (2) Declarative UI

Files containing strings referenced in the declarative UI (`*.ui.xml` files).

These have names matching `*BinderImplGenMessages_en.properties` where the wildcard is the name
of the associated `.ui.xml` file.

One example (there are many others) is:

- `src/org/rstudio/studio/client/panmirror/dialogs/PanmirrorEditRawDialogBinderImplGenMessages_en.properties`

which is associated with

- `src/org/rstudio/studio/client/panmirror/dialogs/PanmirrorEditRawDialog.ui.xml`

### (3) All Others

Strings not generated by the build process or associated with a declarative UI file.

One example (there are many others) is

- `src/org/rstudio/studio/client/workbench/views/source/editors/text/EditorsTextConstants_en.properties`

which is associated with the Java class

- `src/org/rstudio/studio/client/workbench/views/source/editors/text/EditorsTextConstants.java`

All files in this category will following this naming convention where the part before `_en.properties`
is the name of the associated Java class.

In addition to matching the `*Constants.java` filename, only those files containing an 
`interface` that extends either `Messages` or `Constants`.

The Java class file contains entries of the form:

```java
    String chunkHtmlPageOutputFrame();
```

These have entries in the properties file where the key matches the method name.

```properties
chunkHtmlPageOutputFrame=Chunk HTML Page Output Frame
```

There is a special case when handling plural forms. This is currently only used once in the
`RSConnectConstants` class, as follows:

```java
@DefaultMessage("{0,number} environment variables will be published with this {1}.")
@AlternateMessage({"one", "1 environment variable will be published with this {1}."})
String envVarsPublishMessage(@PluralCount int itemCount, String contentType);
```

The matching properties are:

```properties
envVarsPublishMessage={0,number} environment variables will be published with this {1}.
envVarsPublishMessage[one]=1 environment variable will be published with this {1}.
```

## Other Considerations

- the key is case-sensitive
- the rules for escaping single-quotes in `.properties` files:
    - if the associatated Java class derives from `Constants` then only strings using placeholders
      such as {0}, {1}, etc. need to use `''` to represent a single `'`; strings not using 
      placeholders should use `'`
    - if the associated Java class derives from `Messages` then all strings must use `''` to 
      represent `'` whether or not they have placeholders

## Documentation on GWT i18n support

- https://www.gwtproject.org/doc/latest/DevGuideI18n.html

