diff --git a/plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
index 6d2ccbac07a5d7fecb082a9f28c5b7f591347a91..72d4eb866aefa8aa01d3afecf5e5aae1eaa3d619 100644
--- a/plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
@@ -22,6 +22,7 @@ extension-point.org.jkiss.dbeaver.sql.covertname = SQL text conversions
extension-point.org.jkiss.dbeaver.tools.name = Tools
extension-point.org.jkiss.dbeaver.product.bundles.name = Product bundles
extension-point.org.jkiss.dbeaver.workbenchHandler.name = Workbench handlers
+extension-point.org.jkiss.dbeaver.language.name = Language
content-type.org.jkiss.dbeaver.sql.name = SQL Script
content-type.org.jkiss.dbeaver.bookmark.name = Bookmark
@@ -36,6 +37,12 @@ view.database.output.title=Output
menu.navigate=Navigate
+language.en.label=English
+language.zh.label=Chinese
+language.ru.label=Russian
+language.it.label=Italian
+language.de.label=German
+
editor.sql.name=SQL Editor
editor.folder.name=Folder Editor
editor.entity.name=Entity Editor
diff --git a/plugins/org.jkiss.dbeaver.core/plugin.xml b/plugins/org.jkiss.dbeaver.core/plugin.xml
index 4278bb20b06a346eecd99923e0e3e910090c0376..07c711b08ae29c6d611f04ea5b5b7467e8a16a77 100644
--- a/plugins/org.jkiss.dbeaver.core/plugin.xml
+++ b/plugins/org.jkiss.dbeaver.core/plugin.xml
@@ -39,6 +39,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Plugin Service
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [Enter the first release in which this extension point appears.]
+
+
+
+
+
+
+
+
+ [Enter extension point usage example here.]
+
+
+
+
+
+
+
+
+ [Enter API information here.]
+
+
+
+
+
+
+
+
+ [Enter information about supplied implementation of this extension point.]
+
+
+
+
+
diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
index b98e40c28b349f98445955982fcd2fd9b6f38369..ef3e9229c95e2719a74a08ffa93a2d4cd470eae8 100644
--- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
+++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
@@ -47,6 +47,7 @@ import org.jkiss.dbeaver.registry.PluginServiceRegistry;
import org.jkiss.dbeaver.registry.ProjectRegistry;
import org.jkiss.dbeaver.registry.datatype.DataTypeProviderRegistry;
import org.jkiss.dbeaver.registry.editor.EntityEditorsRegistry;
+import org.jkiss.dbeaver.registry.language.PlatformLanguageRegistry;
import org.jkiss.dbeaver.registry.sql.SQLFormatterConfigurationRegistry;
import org.jkiss.dbeaver.runtime.IPluginService;
import org.jkiss.dbeaver.runtime.jobs.KeepAliveJob;
@@ -79,7 +80,7 @@ public class DBeaverCore implements DBPPlatform {
private static final Log log = Log.getLog(DBeaverCore.class);
public static final String TEMP_PROJECT_NAME = ".dbeaver-temp"; //$NON-NLS-1$
- public static final String RUNTIME_LOCALE_PROP = "runtime-locale"; //$NON-NLS-1$
+ public static final String PLATFORM_LANGUAGE_PROP = "platform-language"; //$NON-NLS-1$
private static final DBPApplication DEFAULT_APPLICATION = new EclipseApplication();
@@ -91,7 +92,7 @@ public class DBeaverCore implements DBPPlatform {
private File tempFolder;
private IWorkspace workspace;
- private Locale runtimeLocale = Locale.getDefault();
+ private DBPPlatformLanguage language;
private OSDescriptor localSystem;
private DBNModel navigatorModel;
@@ -192,16 +193,18 @@ public class DBeaverCore implements DBPPlatform {
this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
{
- String runtimeLocaleString = prefsStore.getString(RUNTIME_LOCALE_PROP);
+ String runtimeLocaleString = prefsStore.getString(PLATFORM_LANGUAGE_PROP);
if (!CommonUtils.isEmpty(runtimeLocaleString)) {
- this.runtimeLocale = Locale.forLanguageTag(runtimeLocaleString);
- if (this.runtimeLocale == null) {
+ this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.forLanguageTag(runtimeLocaleString));
+ if (this.language == null) {
log.warn("Runtime locale '" + runtimeLocaleString + "' not found");
- this.runtimeLocale = Locale.getDefault();
} else {
- changeRuntimeLocale(runtimeLocale);
+ changeRuntimeLocale(this.language);
}
}
+ if (this.language == null) {
+ this.language = PlatformLanguageRegistry.getInstance().getLanguage(Locale.ENGLISH);
+ }
}
QMUtils.initApplication(this);
@@ -346,21 +349,24 @@ public class DBeaverCore implements DBPPlatform {
@NotNull
@Override
- public Locale getRuntimeLocale() {
- return runtimeLocale;
+ public DBPPlatformLanguage getLanguage() {
+ return language;
}
- public void setRuntimeLocale(@NotNull Locale runtimeLocale) {
- changeRuntimeLocale(runtimeLocale);
- this.runtimeLocale = runtimeLocale;
- getGlobalPreferenceStore().setValue(RUNTIME_LOCALE_PROP, runtimeLocale.toString());
+ public void setPlatformLanguage(@NotNull DBPPlatformLanguage language) {
+ if (CommonUtils.equalObjects(language, this.language)) {
+ return;
+ }
+ changeRuntimeLocale(language);
+ this.language = language;
+ getGlobalPreferenceStore().setValue(PLATFORM_LANGUAGE_PROP, language.getCode());
}
- private void changeRuntimeLocale(@NotNull Locale runtimeLocale) {
+ private void changeRuntimeLocale(@NotNull DBPPlatformLanguage runtimeLocale) {
// Check locale
ILocaleChangeService localeService = PlatformUI.getWorkbench().getService(ILocaleChangeService.class);
if (localeService != null) {
- localeService.changeApplicationLocale(runtimeLocale);
+ localeService.changeApplicationLocale(runtimeLocale.getCode());
} else {
log.warn("Can't resolve locale change service");
}
diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java
index 831c86464368442cab3c5910f76fdd50b945feeb..77556aa73afc12beebdc213120db4a189f20c5a0 100644
--- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java
+++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/RegistryConstants.java
@@ -77,6 +77,7 @@ public class RegistryConstants {
public static final String ATTR_DRIVER = "driver"; //$NON-NLS-1$
public static final String ATTR_BUNDLE = "bundle"; //$NON-NLS-1$
+ public static final String ATTR_CODE = "code"; //$NON-NLS-1$
public static final String ATTR_LABEL = "label"; //$NON-NLS-1$
public static final String ATTR_DEFAULT_PORT = "defaultPort"; //$NON-NLS-1$
public static final String ATTR_SAMPLE_URL = "sampleURL"; //$NON-NLS-1$
diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageDescriptor.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageDescriptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..2110450a3b9d960b6499b37f2cfd8ce6d00c1cd4
--- /dev/null
+++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageDescriptor.java
@@ -0,0 +1,64 @@
+/*
+ * DBeaver - Universal Database Manager
+ * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jkiss.dbeaver.registry.language;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.jkiss.code.NotNull;
+import org.jkiss.dbeaver.model.app.DBPPlatformLanguage;
+import org.jkiss.dbeaver.registry.AbstractContextDescriptor;
+import org.jkiss.dbeaver.registry.RegistryConstants;
+
+/**
+ * PlatformLanguageDescriptor
+ */
+public class PlatformLanguageDescriptor extends AbstractContextDescriptor implements DBPPlatformLanguage
+{
+ public static final String EXTENSION_ID = "org.jkiss.dbeaver.language"; //$NON-NLS-1$
+
+ private final String code;
+ private final String label;
+ private final String description;
+
+ public PlatformLanguageDescriptor(
+ IConfigurationElement config)
+ {
+ super(config);
+
+ this.code = config.getAttribute(RegistryConstants.ATTR_CODE);
+ this.label = config.getAttribute(RegistryConstants.ATTR_LABEL);
+ this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
+ }
+
+ @NotNull
+ @Override
+ public String getCode() {
+ return code;
+ }
+
+ @NotNull
+ @Override
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+}
diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageRegistry.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..075dd03241a55b2e41c9a8a631d3a8e07f315a4f
--- /dev/null
+++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/language/PlatformLanguageRegistry.java
@@ -0,0 +1,78 @@
+/*
+ * DBeaver - Universal Database Manager
+ * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jkiss.dbeaver.registry.language;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class PlatformLanguageRegistry
+{
+ private static PlatformLanguageRegistry instance = null;
+
+ public synchronized static PlatformLanguageRegistry getInstance()
+ {
+ if (instance == null) {
+ instance = new PlatformLanguageRegistry(Platform.getExtensionRegistry());
+ }
+ return instance;
+ }
+
+ private final List descriptors = new ArrayList<>();
+
+ private PlatformLanguageRegistry(IExtensionRegistry registry)
+ {
+ // Load data descriptors from external plugins
+ {
+ IConfigurationElement[] extElements = registry.getConfigurationElementsFor(PlatformLanguageDescriptor.EXTENSION_ID);
+ for (IConfigurationElement ext : extElements) {
+ PlatformLanguageDescriptor formatterDescriptor = new PlatformLanguageDescriptor(ext);
+ descriptors.add(formatterDescriptor);
+ }
+ }
+ }
+
+ public List getLanguages()
+ {
+ return descriptors;
+ }
+
+ public PlatformLanguageDescriptor getLanguage(String id)
+ {
+ for (PlatformLanguageDescriptor descriptor : descriptors) {
+ if (descriptor.getCode().equals(id)) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+ public PlatformLanguageDescriptor getLanguage(Locale locale)
+ {
+ for (PlatformLanguageDescriptor descriptor : descriptors) {
+ if (descriptor.getCode().equals(locale.getLanguage())) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
index b5b61a0d84e12a241da00d4f89286d318b1380ff..33d739fa71bedd090a16e4b652edebbfd1bd3c34 100644
--- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
+++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageDatabaseGeneral.java
@@ -33,13 +33,19 @@ import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
+import org.jkiss.dbeaver.model.app.DBPPlatformLanguage;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
+import org.jkiss.dbeaver.registry.language.PlatformLanguageDescriptor;
+import org.jkiss.dbeaver.registry.language.PlatformLanguageRegistry;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.TextWithOpenFile;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.PrefUtils;
import org.jkiss.dbeaver.utils.RuntimeUtils;
import org.jkiss.dbeaver.utils.SystemVariablesResolver;
+import org.jkiss.utils.CommonUtils;
+
+import java.util.List;
/**
* PrefPageDatabaseGeneral
@@ -49,6 +55,7 @@ public class PrefPageDatabaseGeneral extends AbstractPrefPage implements IWorkbe
public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.main.common"; //$NON-NLS-1$
private Button automaticUpdateCheck;
+ private Combo workspaceLanguage;
private Button longOperationsCheck;
private Spinner longOperationsTimeout;
@@ -76,9 +83,23 @@ public class PrefPageDatabaseGeneral extends AbstractPrefPage implements IWorkbe
Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
{
- Group groupObjects = UIUtils.createControlGroup(composite, CoreMessages.pref_page_ui_general_group_general, 1, GridData.VERTICAL_ALIGN_BEGINNING, 300);
- automaticUpdateCheck = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_ui_general_checkbox_automatic_updates, false);
- automaticUpdateCheck.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 2, 1));
+ Group groupObjects = UIUtils.createControlGroup(composite, CoreMessages.pref_page_ui_general_group_general, 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
+ automaticUpdateCheck = UIUtils.createCheckbox(groupObjects, CoreMessages.pref_page_ui_general_checkbox_automatic_updates, null, false, 2);
+ //automaticUpdateCheck.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 2, 1));
+
+ workspaceLanguage = UIUtils.createLabelCombo(groupObjects, "Language", "Application language - used for UI localization", SWT.READ_ONLY | SWT.DROP_DOWN);
+ List languages = PlatformLanguageRegistry.getInstance().getLanguages();
+ DBPPlatformLanguage pLanguage = DBeaverCore.getInstance().getLanguage();
+ for (int i = 0; i < languages.size(); i++) {
+ PlatformLanguageDescriptor lang = languages.get(i);
+ workspaceLanguage.add(lang.getLabel());
+ if (CommonUtils.equalObjects(pLanguage, lang)) {
+ workspaceLanguage.select(i);
+ }
+ }
+ if (workspaceLanguage.getSelectionIndex() < 0) {
+ workspaceLanguage.select(0);
+ }
}
// Agent settings
@@ -165,6 +186,10 @@ public class PrefPageDatabaseGeneral extends AbstractPrefPage implements IWorkbe
@Override
public boolean performOk()
{
+ if (workspaceLanguage.getSelectionIndex() >= 0) {
+ PlatformLanguageDescriptor language = PlatformLanguageRegistry.getInstance().getLanguages().get(workspaceLanguage.getSelectionIndex());
+ DBeaverCore.getInstance().setPlatformLanguage(language);
+ }
DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
store.setValue(DBeaverPreferences.UI_AUTO_UPDATE_CHECK, automaticUpdateCheck.getSelection());
diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
index 45857fc88e938a55c1b01f19bee8b64d16739bb8..b931f9e95e94a1364cf2d63e5f6f313c4bdbf6e8 100644
--- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
+++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
@@ -42,7 +42,7 @@ public interface DBPPlatform
DBPApplication getApplication();
@NotNull
- Locale getRuntimeLocale();
+ DBPPlatformLanguage getLanguage();
@NotNull
DBNModel getNavigatorModel();
diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatformLanguage.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatformLanguage.java
new file mode 100644
index 0000000000000000000000000000000000000000..af26456ce9b5351442bb752ba6d6e4e4f65c3792
--- /dev/null
+++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatformLanguage.java
@@ -0,0 +1,29 @@
+/*
+ * DBeaver - Universal Database Manager
+ * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jkiss.dbeaver.model.app;
+
+/**
+ * DBPPlatformLanguage
+ */
+public interface DBPPlatformLanguage
+{
+ String getCode();
+
+ String getLabel();
+
+}