1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 558516 - Normalize i18n for CDT LSP component

Revisited all the i18n

Change-Id: Ic5b14ee68cb3d0164f179a9d2690573a82f356d8
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
Alexander Fedorov 2019-12-20 20:32:38 +03:00 committed by Jonah Graham
parent a95c9a486e
commit b72a6c3d93
14 changed files with 208 additions and 97 deletions

View file

@ -23,7 +23,9 @@ Require-Bundle: com.google.gson;bundle-version="2.8.2",
org.eclipse.cdt.ui
Import-Package: org.eclipse.ui.editors.text,
org.eclipse.ui.texteditor
Export-Package: org.eclipse.cdt.lsp.core,
org.eclipse.cdt.lsp.core.cquery
Export-Package: org.eclipse.cdt.lsp.core;x-internal:=true,
org.eclipse.cdt.lsp.core.cquery;x-internal:=true,
org.eclipse.cdt.lsp.internal.core;x-internal:=true,
org.eclipse.cdt.lsp.internal.ui;x-internal:=true
Bundle-Activator: org.eclipse.cdt.lsp.core.Activator
Bundle-ActivationPolicy: lazy

View file

@ -1,18 +1,23 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
* Copyright (c) 2018-2019 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Manish Khurana <mkmanishkhurana98@gmail.com> - initial API and implementation
* Nathan Ridge <zeratul976@hotmail.com> - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core;
import java.io.File;
import org.eclipse.cdt.lsp.internal.ui.LspUiMessages;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
@ -35,24 +40,27 @@ public class CPPLanguageServerPreferencePage extends FieldEditorPreferencePage i
public CPPLanguageServerPreferencePage() {
super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription(Messages.PreferencePageDescription);
setDescription(LspUiMessages.CPPLanguageServerPreferencePage_description);
}
@Override
public void createFieldEditors() {
serverChoice = new RadioGroupFieldEditor(PreferenceConstants.P_SERVER_CHOICE, Messages.ServerChoiceLabel, 1,
new String[][] { { "ClangD", CPPStreamConnectionProvider.CLANGD_ID }, //$NON-NLS-1$
{ "CQuery", CPPStreamConnectionProvider.CQUERY_ID } }, //$NON-NLS-1$
serverChoice = new RadioGroupFieldEditor(PreferenceConstants.P_SERVER_CHOICE,
LspUiMessages.CPPLanguageServerPreferencePage_server_selector, 1,
new String[][] {
{ LspUiMessages.CPPLanguageServerPreferencePage_clangd, CPPStreamConnectionProvider.CLANGD_ID },
{ LspUiMessages.CPPLanguageServerPreferencePage_cquery,
CPPStreamConnectionProvider.CQUERY_ID } },
getFieldEditorParent());
addField(serverChoice);
serverPath = new FileFieldEditor(PreferenceConstants.P_SERVER_PATH, Messages.ServerPathLabel,
getFieldEditorParent());
serverPath = new FileFieldEditor(PreferenceConstants.P_SERVER_PATH,
LspUiMessages.CPPLanguageServerPreferencePage_server_path, getFieldEditorParent());
addField(serverPath);
serverOptions = new StringFieldEditor(PreferenceConstants.P_SERVER_OPTIONS, Messages.ServerOptionsLabel,
getFieldEditorParent());
serverOptions = new StringFieldEditor(PreferenceConstants.P_SERVER_OPTIONS,
LspUiMessages.CPPLanguageServerPreferencePage_server_options, getFieldEditorParent());
addField(serverOptions);
}

View file

@ -1,12 +1,15 @@
/*******************************************************************************
* Copyright (c) 2017 Ericsson and others.
* Copyright (c) 2017-2019 Ericsson and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Ericsson - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core;
@ -22,13 +25,14 @@ import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.lsp4e.LanguageServerWrapper;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.LanguageServerWrapper;
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
import org.eclipse.lsp4j.FileChangeType;
import org.eclipse.lsp4j.FileEvent;
import org.eclipse.osgi.util.NLS;
/**
* A resource listener used to generate FileEvents, as part of the LSP. This
@ -114,7 +118,7 @@ final class CPPResourceChangeListener implements IResourceChangeListener {
} else if (delta.getKind() == IResourceDelta.REMOVED) {
changeType = FileChangeType.Deleted;
} else {
throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind()); //$NON-NLS-1$
throw new IllegalStateException(NLS.bind("Unsupported resource delta kind: {0}", delta.getKind())); //$NON-NLS-1$
}
return new FileEvent(locationURI.toString(), changeType);

View file

@ -1,12 +1,15 @@
/*******************************************************************************
* Copyright (c) 2017 Ericsson and others.
* Copyright (c) 2017-2019 Ericsson and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Ericsson - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core;
@ -20,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.eclipse.cdt.lsp.internal.core.LspCoreMessages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeListener;
@ -49,7 +53,7 @@ public class CPPStreamConnectionProvider extends ProcessStreamConnectionProvider
} else if (store.getString(PreferenceConstants.P_SERVER_CHOICE).equals(CLANGD_ID)) {
languageServer = new ClangdLanguageServer();
} else {
throw new UnsupportedOperationException("Unsupported Language Server"); //$NON-NLS-1$
throw new UnsupportedOperationException(LspCoreMessages.CPPStreamConnectionProvider_e_unsupported);
}
File defaultLSLocation = getDefaultLSLocation(store.getString(PreferenceConstants.P_SERVER_CHOICE));
if (defaultLSLocation != null) {

View file

@ -1,27 +0,0 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.lsp.core;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
public static String PreferencePageDescription;
public static String ServerChoiceLabel;
public static String ServerPathLabel;
public static String ServerOptionsLabel;
public static String CqueryStateIdle;
public static String CqueryStateBusy;
static {
NLS.initializeMessages(Messages.class.getName(), Messages.class);
}
}

View file

@ -1,17 +0,0 @@
################################################################################
# Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#################################################################################
PreferencePageDescription=Preferences for the C/C++ Language Server\n\n
ServerChoiceLabel=Please select the C/C++ Language Server you want to use in Eclipse :
ServerPathLabel=Browse path to the server executable
ServerOptionsLabel=Enter any command-line options for the server
CqueryStateIdle=CQuery : Idle
CqueryStateBusy=CQuery : Busy | {0} Jobs

View file

@ -1,12 +1,16 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
* Copyright (c) 2018-2019 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Manish Khurana <mkmanishkhurana98@gmail.com> - initial API and implementation
* Nathan Ridge <zeratul976@hotmail.com> - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core;
@ -21,6 +25,7 @@ import org.eclipse.cdt.lsp.core.cquery.CqueryInactiveRegions;
import org.eclipse.cdt.lsp.core.cquery.CquerySemanticHighlights;
import org.eclipse.cdt.lsp.core.cquery.HighlightSymbol;
import org.eclipse.cdt.lsp.core.cquery.IndexingProgressStats;
import org.eclipse.cdt.lsp.internal.core.LspCoreMessages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.core.resources.IFile;
@ -65,8 +70,9 @@ public class Server2ClientProtocolExtension extends LanguageClientImpl {
cqueryStatusField = new StatusLineContributionItem(cqueryStatusFieldId, width);
statusLine.add(cqueryStatusField);
}
String msg = stats.getTotalJobs() > 0 ? NLS.bind(Messages.CqueryStateBusy, stats.getTotalJobs())
: Messages.CqueryStateIdle;
String msg = stats.getTotalJobs() > 0
? NLS.bind(LspCoreMessages.Server2ClientProtocolExtension_cquery_busy, stats.getTotalJobs())
: LspCoreMessages.Server2ClientProtocolExtension_cquery_idle;
cqueryStatusField.setText(msg);
}
});

View file

@ -1,16 +1,23 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
* Copyright (c) 2018-2019 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Manish Khurana <mkmanishkhurana98@gmail.com> - initial API and implementation
* Nathan Ridge <zeratul976@hotmail.com> - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core.cquery;
import org.eclipse.cdt.lsp.internal.core.LspCoreMessages;
import org.eclipse.osgi.util.NLS;
enum CquerySymbolKind {
Unknown(0), TypeAlias(252), Parameter(253), StaticMethod(254), Macro(255);
@ -37,7 +44,7 @@ enum CquerySymbolKind {
case 255:
return CquerySymbolKind.Macro;
default:
throw new IllegalArgumentException("Illegal value for cquery symbol kind"); //$NON-NLS-1$
throw new IllegalArgumentException(NLS.bind(LspCoreMessages.CquerySymbolKind_e_illegal_value, value));
}
}
}

View file

@ -1,12 +1,16 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
* Copyright (c) 2018-2019 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Manish Khurana <mkmanishkhurana98@gmail.com> - initial API and implementation
* Nathan Ridge <zeratul976@hotmail.com> - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core.cquery;
@ -29,6 +33,7 @@ public class ExtendedSymbolKindType {
int value;
transient boolean isProtocolSymbol;
//FIXME: let's rework this example of "Exception-driven programming"
public ExtendedSymbolKindType(int _v) {
try {
SymbolKind.forValue(_v);
@ -40,7 +45,7 @@ public class ExtendedSymbolKindType {
value = _v;
isProtocolSymbol = false;
} catch (IllegalArgumentException y) {
throw new IllegalArgumentException("Illegal value for SymbolKind"); //$NON-NLS-1$
throw y;
}
}
}

View file

@ -1,16 +1,23 @@
/*******************************************************************************
* Copyright (c) 2018 Manish Khurana , Nathan Ridge and others.
* Copyright (c) 2018-2019 Manish Khurana, Nathan Ridge and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Manish Khurana <mkmanishkhurana98@gmail.com> - initial API and implementation
* Nathan Ridge <zeratul976@hotmail.com> - initial API and implementation
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558516
*******************************************************************************/
package org.eclipse.cdt.lsp.core.cquery;
import org.eclipse.cdt.lsp.internal.core.LspCoreMessages;
import org.eclipse.osgi.util.NLS;
public enum StorageClass {
Invalid(0), None(1), Extern(2), Static(3), PrivateExtern(4), Auto(5), Register(6);
@ -27,7 +34,7 @@ public enum StorageClass {
public static StorageClass forValue(int value) {
StorageClass[] allValues = StorageClass.values();
if (value < 1 || value > allValues.length) {
throw new IllegalArgumentException("Illegal enum value: " + value); //$NON-NLS-1$
throw new IllegalArgumentException(NLS.bind(LspCoreMessages.StorageClass_e_illegal_value, value));
}
return allValues[value - 1];
}

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2019 Eclipse Foundation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - initial API and implementatin
*******************************************************************************/
package org.eclipse.cdt.lsp.internal.core;
import org.eclipse.osgi.util.NLS;
public class LspCoreMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.lsp.internal.core.LspCoreMessages"; //$NON-NLS-1$
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, LspCoreMessages.class);
}
public static String CPPStreamConnectionProvider_e_unsupported;
public static String CquerySymbolKind_e_illegal_value;
public static String Server2ClientProtocolExtension_cquery_busy;
public static String Server2ClientProtocolExtension_cquery_idle;
public static String StorageClass_e_illegal_value;
private LspCoreMessages() {
}
}

View file

@ -0,0 +1,19 @@
###############################################################################
# Copyright (c) 2019 Eclipse Foundation and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eclipse Foundation - initial API and implementation
# Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558484
###############################################################################
CPPStreamConnectionProvider_e_unsupported=Unsupported Language Server
CquerySymbolKind_e_illegal_value=Illegal value {0} for cquery symbol kind
Server2ClientProtocolExtension_cquery_busy=CQuery : Busy | {0} Jobs
Server2ClientProtocolExtension_cquery_idle=CQuery : Idle
StorageClass_e_illegal_value=Illegal enum value: {0}

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2019 Eclipse Foundation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - initial API and implementatin
*******************************************************************************/
package org.eclipse.cdt.lsp.internal.ui;
import org.eclipse.osgi.util.NLS;
public class LspUiMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.lsp.internal.ui.LspUiMessages"; //$NON-NLS-1$
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, LspUiMessages.class);
}
public static String CPPLanguageServerPreferencePage_clangd;
public static String CPPLanguageServerPreferencePage_cquery;
public static String CPPLanguageServerPreferencePage_description;
public static String CPPLanguageServerPreferencePage_server_options;
public static String CPPLanguageServerPreferencePage_server_path;
public static String CPPLanguageServerPreferencePage_server_selector;
private LspUiMessages() {
}
}

View file

@ -0,0 +1,22 @@
###############################################################################
# Copyright (c) 2019 Eclipse Foundation and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eclipse Foundation - initial API and implementation
# Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 558484
###############################################################################
CPPLanguageServerPreferencePage_clangd=ClangD
CPPLanguageServerPreferencePage_cquery=CQuery
CPPLanguageServerPreferencePage_description=Preferences for the C/C++ Language Server\n\n
CPPLanguageServerPreferencePage_server_options=Enter any command-line options for the server
CPPLanguageServerPreferencePage_server_path=Browse path to the server executable
CPPLanguageServerPreferencePage_server_selector=Please select the C/C++ Language Server you want to use in Eclipse :