LanguagePreferences

Inheritance: java.lang.Object

public class LanguagePreferences

Allows to set up language preferences.

To learn more, visit the Specify Load Options documentation article.

Remarks:

Implements ‘Set the Office Language Preferences’ dialog in Word.

Examples:

Shows how to apply language preferences when loading a document.


 LoadOptions loadOptions = new LoadOptions();
 loadOptions.getLanguagePreferences().addEditingLanguage(EditingLanguage.JAPANESE);

 Document doc = new Document(getMyDir() + "No default editing language.docx", loadOptions);

 int localeIdFarEast = doc.getStyles().getDefaultFont().getLocaleIdFarEast();
 System.out.println(localeIdFarEast == EditingLanguage.JAPANESE
         ? "The document either has no any FarEast language set in defaults or it was set to Japanese originally."
         : "The document default FarEast language was set to another than Japanese language originally, so it is not overridden.");
 

Methods

MethodDescription
addEditingLanguage(int language)
addEditingLanguages(int[] languages)
getDefaultEditingLanguage()Gets or sets default editing language.
setDefaultEditingLanguage(int value)Gets or sets default editing language.

addEditingLanguage(int language)

public void addEditingLanguage(int language)

Parameters:

ParameterTypeDescription
languageint

addEditingLanguages(int[] languages)

public void addEditingLanguages(int[] languages)

Parameters:

ParameterTypeDescription
languagesint[]

getDefaultEditingLanguage()

public int getDefaultEditingLanguage()

Gets or sets default editing language.

The default value is EditingLanguage.ENGLISH_US.

Examples:

Shows how set a default language when loading a document.


 LoadOptions loadOptions = new LoadOptions();
 loadOptions.getLanguagePreferences().setDefaultEditingLanguage(EditingLanguage.RUSSIAN);

 Document doc = new Document(getMyDir() + "No default editing language.docx", loadOptions);

 int localeId = doc.getStyles().getDefaultFont().getLocaleId();
 System.out.println(localeId == EditingLanguage.RUSSIAN
         ? "The document either has no any language set in defaults or it was set to Russian originally."
         : "The document default language was set to another than Russian language originally, so it is not overridden.");
 

Returns: int - The corresponding int value. The returned value is one of EditingLanguage constants.

setDefaultEditingLanguage(int value)

public void setDefaultEditingLanguage(int value)

Gets or sets default editing language.

The default value is EditingLanguage.ENGLISH_US.

Examples:

Shows how set a default language when loading a document.


 LoadOptions loadOptions = new LoadOptions();
 loadOptions.getLanguagePreferences().setDefaultEditingLanguage(EditingLanguage.RUSSIAN);

 Document doc = new Document(getMyDir() + "No default editing language.docx", loadOptions);

 int localeId = doc.getStyles().getDefaultFont().getLocaleId();
 System.out.println(localeId == EditingLanguage.RUSSIAN
         ? "The document either has no any language set in defaults or it was set to Russian originally."
         : "The document default language was set to another than Russian language originally, so it is not overridden.");
 

Parameters:

ParameterTypeDescription
valueintThe corresponding int value. The value must be one of EditingLanguage constants.