Make "Assmbler"/"Compiler" text language dependent and have correct

sentence/title case in messages
This commit is contained in:
Peter Dell 2022-12-27 00:39:28 +01:00
parent fc48aa17e9
commit 1e11d6326c
9 changed files with 61 additions and 34 deletions

View File

@ -50,15 +50,15 @@ public final class LanguageUtility {
* Gets the text for type of compilers for a language.
*
* @param language The language, not <code>null</code>.
* @return The text, not empty and not <code>null</code>.
* @return The text in sentence case, not empty and not <code>null</code>.
*/
public static String getCompilerTextLower(Language language) {
public static String getCompilerText(Language language) {
switch (language) {
case ASM:
return "assembler"; // TODO: Have translation, so lower/upper is correct in German
return Texts.LANGUAGE_ASSEMBLER_TEXT;
case PAS:
return "compiler";
return Texts.LANGUAGE_COMPILER_TEXT;
}
throw new IllegalArgumentException("Unknown language '" + language + "'.");
@ -68,10 +68,10 @@ public final class LanguageUtility {
public static String getCompilerPreferencesText(Language language) {
switch (language) {
case ASM:
return "Languages/Assemblers";
return Texts.LANGUAGES_TITLE_CASE+"/"+Texts.LANGUAGE_ASSEMBLER_TEXT_TITLE_CASE;
case PAS:
return "Languages/Compilers";
return Texts.LANGUAGES_TITLE_CASE+"/"+Texts.LANGUAGE_COMPILER_TEXT_TITLE_CASE;
}
throw new IllegalArgumentException("Unknown language '" + language + "'.");

View File

@ -28,21 +28,14 @@ import org.eclipse.osgi.util.NLS;
*/
public final class Texts extends NLS {
public static String TOC_COMPILER_SYNTAX_YES;
public static String TOC_COMPILER_SYNTAX_NO;
public static String TOC_COMPILER_SYNTAX_BLOCK_DEFINITION_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_COMPLETION_PROPOSAL_AUTO_ACTIVATION_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_PART_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_SEPARATOR_CHARACTER;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_START_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIERS_CASE_SENSITIVE;
public static String TOC_COMPILER_SYNTAX_INSTRUCTIONS_CASE_SENSITIVE;
public static String TOC_COMPILER_SYNTAX_LABEL_DEFINITION_SUFFIX_CHARACTER;
public static String TOC_COMPILER_SYNTAX_MACRO_USAGE_PREFIX_CHARACTER;
public static String TOC_COMPILER_SYNTAX_MULTIPLE_LINES_COMMENT_DELIMITERS;
public static String TOC_COMPILER_SYNTAX_SINGLE_LINE_COMMENT_DELIMITERS;
public static String TOC_COMPILER_SYNTAX_SOURCE_INCLUDE_DEFAULT_EXTENSION;
public static String TOC_COMPILER_SYNTAX_STRING_DELIMITERS;
/**
* Languages,
*/
public static String LANGUAGES_TITLE_CASE;
public static String LANGUAGE_ASSEMBLER_TEXT_TITLE_CASE;
public static String LANGUAGE_ASSEMBLER_TEXT;
public static String LANGUAGE_COMPILER_TEXT_TITLE_CASE;
public static String LANGUAGE_COMPILER_TEXT;
/**
* Compiler console.
@ -223,6 +216,22 @@ public final class Texts extends NLS {
public static String TOC_COMPILER_INSTRUCTION_DESCRIPTION_LABEL;
public static String TOC_COMPILER_MANUAL_TOPIC_LABEL;
public static String TOC_COMPILER_SYNTAX_YES;
public static String TOC_COMPILER_SYNTAX_NO;
public static String TOC_COMPILER_SYNTAX_BLOCK_DEFINITION_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_COMPLETION_PROPOSAL_AUTO_ACTIVATION_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_PART_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_SEPARATOR_CHARACTER;
public static String TOC_COMPILER_SYNTAX_IDENTIFIER_START_CHARACTERS;
public static String TOC_COMPILER_SYNTAX_IDENTIFIERS_CASE_SENSITIVE;
public static String TOC_COMPILER_SYNTAX_INSTRUCTIONS_CASE_SENSITIVE;
public static String TOC_COMPILER_SYNTAX_LABEL_DEFINITION_SUFFIX_CHARACTER;
public static String TOC_COMPILER_SYNTAX_MACRO_USAGE_PREFIX_CHARACTER;
public static String TOC_COMPILER_SYNTAX_MULTIPLE_LINES_COMMENT_DELIMITERS;
public static String TOC_COMPILER_SYNTAX_SINGLE_LINE_COMMENT_DELIMITERS;
public static String TOC_COMPILER_SYNTAX_SOURCE_INCLUDE_DEFAULT_EXTENSION;
public static String TOC_COMPILER_SYNTAX_STRING_DELIMITERS;
public static String TOC_HARDWARES_TOPIC_LABEL;
public static String TOC_HARDWARE_NAME_LABEL;
public static String TOC_HARDWARE_ID_LABEL;

View File

@ -1,3 +1,9 @@
LANGUAGES_TITLE_CASE=Languages
LANGUAGE_ASSEMBLER_TEXT_TITLE_CASE=Assembler
LANGUAGE_ASSEMBLER_TEXT=assembler
LANGUAGE_COMPILER_TEXT_TITLE_CASE=Compiler
LANGUAGE_COMPILER_TEXT=compiler
COMPILER_CONSOLE_TITLE=Compiler Console
COMPILER_SOURCE_PARSER_TREE_OBJECT_TYPE_DEFAULT=Default

View File

@ -1,3 +1,9 @@
LANGUAGES_TITLE_CASE=Sprachen
LANGUAGE_ASSEMBLER_TEXT_TITLE_CASE=Assembler
LANGUAGE_ASSEMBLER_TEXT=Assembler
LANGUAGE_COMPILER_TEXT_TITLE_CASE=Kompiler
LANGUAGE_COMPILER_TEXT=Kompiler
COMPILER_CONSOLE_TITLE=Kompiler Konsole
COMPILER_SOURCE_PARSER_TREE_OBJECT_TYPE_DEFAULT=Default

View File

@ -1,3 +1,9 @@
LANGUAGES_TITLE_CASE=j\u0119zyki
LANGUAGE_ASSEMBLER_TEXT_TITLE_CASE=Assembler
LANGUAGE_ASSEMBLER_TEXT=assembler
LANGUAGE_COMPILER_TEXT_TITLE_CASE=Kompilator
LANGUAGE_COMPILER_TEXT=kompilator
COMPILER_CONSOLE_TITLE=Konsola kompilatora
COMPILER_SOURCE_PARSER_TREE_OBJECT_TYPE_DEFAULT=Domy\u015Blny

View File

@ -155,10 +155,10 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
/**
* Gets the text for type of compilers for a language.
*
* @return he text, not empty and not <code>null</code>.
* @return The text in sentence case, not empty and not <code>null</code>.
*/
public final String getTextLower() {
return LanguageUtility.getCompilerTextLower(getLanguage());
public final String getText() {
return LanguageUtility.getCompilerText(getLanguage());
}
/**
@ -314,14 +314,14 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
if (!hasHelpDocuments()) {
// INFO: The {0} '{1}' does not specify help documents.
throw new CoreException(new Status(IStatus.INFO, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E102, getTextLower(), getName())));
TextUtility.format(Texts.MESSAGE_E102, getText(), getName())));
}
String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(language);
if (StringUtility.isEmpty(compilerExecutablePath)) {
// ERROR: Help for the '{0}' {1} cannot be displayed because the path to the
// compiler executable is not set in the {2} preferences.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E130, getTextLower(), getName(), compilerPreferencesText)));
TextUtility.format(Texts.MESSAGE_E130, getText(), getName(), compilerPreferencesText)));
}
return CompilerHelp.getInstalledHelpDocuments(getHelpDocuments(), compilerExecutablePath);
@ -383,7 +383,7 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
// ERROR: Help for the {0} '{1}' cannot be displayed because no help file was
// found in the paths relative to the executable path '{2}'.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E131, getTextLower(), getName(), compilerExecutablePath)));
TextUtility.format(Texts.MESSAGE_E131, getText(), getName(), compilerExecutablePath)));
}
return result;

View File

@ -253,7 +253,7 @@ final class LanguageEditorCompileCommand {
if (StringUtility.isEmpty(compilerExecutablePath)) {
// ERROR: Path to {0} '{1}' executable is not set in the '{2}' preferences.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100,
compilerDefinition.getTextLower(), compilerDefinition.getName(), compilerPreferencesText);
compilerDefinition.getText(), compilerDefinition.getName(), compilerPreferencesText);
return false;
}
File compilerExecutableFile = new File(compilerExecutablePath);
@ -261,7 +261,7 @@ final class LanguageEditorCompileCommand {
// ERROR: Path to {0} '{1}' executable in the '{2}' preferences points to
// non-existing file '{3}'.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E103,
compilerDefinition.getTextLower(), compilerDefinition.getName(), compilerPreferencesText,
compilerDefinition.getText(), compilerDefinition.getName(), compilerPreferencesText,
compilerExecutablePath);
return false;
}
@ -283,7 +283,7 @@ final class LanguageEditorCompileCommand {
if (compilerParameterArray.length == 0) {
// ERROR: The {0} '{1}' does not specify default parameters.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E101,
compilerDefinition.getTextLower(), compilerDefinition.getName());
compilerDefinition.getText(), compilerDefinition.getName());
return false;
}
@ -324,7 +324,7 @@ final class LanguageEditorCompileCommand {
// ERROR: Cannot execute {0} process '{1}' in working directory '{2}'. System
// error: {3}
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E105,
compilerDefinition.getTextLower(), compilerProcess.getCommandArrayString(),
compilerDefinition.getText(), compilerProcess.getCommandArrayString(),
compilerProcess.getWorkingDirectory().getPath(), ex.getMessage());
}
@ -404,7 +404,7 @@ final class LanguageEditorCompileCommand {
// ERROR: {0} process ended with return code {1}. Check the error messages and
// the console log.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E127,
compilerDefinition.getTextLower(),
compilerDefinition.getText(),
NumberUtility.getLongValueDecimalString(compilerProcess.getExitValue()));
}

View File

@ -303,7 +303,7 @@ public final class LanguageEditorFilesLogic {
// ERROR: Output file extension must be set in the preferences of {0} '{1}' or
// via the annotation '{2}'.
createMainSourceFileMessage(files, files.outputFileExtensionProperty, IMarker.SEVERITY_ERROR,
Texts.MESSAGE_E104, compilerDefinition.getTextLower(), compilerDefinition.getName(),
Texts.MESSAGE_E104, compilerDefinition.getText(), compilerDefinition.getName(),
LanguageProperties.OUTPUT_FILE_EXTENSION);
return false;

View File

@ -441,7 +441,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
// ERROR: Path to {0} '{1}' executable is not set in the '{2}' preferences.
String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage());
label.setText(TextUtility.format(Texts.MESSAGE_E100, compilerDefinition.getTextLower(), compilerDefinition.getName(),
label.setText(TextUtility.format(Texts.MESSAGE_E100, compilerDefinition.getText(), compilerDefinition.getName(),
compilerPreferencesText));
Tab tab = new Tab(compilerDefinition, tabs.size(), tabItem, tabContent, disabledControl, controlDecorations);
tabs.put(compilerId, tab);