Compare commits

...

5 Commits

Author SHA1 Message Date
transifex-integration[bot]
7925f667b5 Translate spark_i18n.properties in ru_RU
100% translated source file: 'spark_i18n.properties'
on 'ru_RU'.
2025-09-21 11:32:51 +02:00
Sergey Ponomarev
73715fa0fb SPARK-2351 LanguagePlugin: Always show Language in menu item for non en locales to help those who accidentally changed language 2025-09-21 11:32:05 +02:00
Sergey Ponomarev
68ce7b08ae LanguagePlugin: Use locale.getDisplayName() 2025-09-21 11:32:05 +02:00
Sergey Ponomarev
4499d1eaf2 LanguagePlugin: inline fields to avoid long living garbage 2025-09-21 11:32:05 +02:00
Sergey Ponomarev
8856e6dd3b SPARK-2350: MainWindow: avoid NPE when running from IDE and attempt to restart 2025-09-21 11:30:41 +02:00
3 changed files with 28 additions and 20 deletions

View File

@ -348,27 +348,35 @@ public final class MainWindow extends ChatFrame implements ActionListener {
return classpath.toString();
}
private String getCommandPath() throws IOException{
return getLibDirectory().getParentFile().getCanonicalPath();
private String getCommandPath() throws IOException{
File libDir = getLibDirectory();
if (libDir == null) {
return null;
}
return libDir.getParentFile().getCanonicalPath();
}
public boolean restartApplicationWithScript() {
String command = null;
try {
String commandPath = getCommandPath();
if (commandPath == null) {
return false;
}
if (Spark.isWindows()) {
String sparkExe = getCommandPath() + File.separator + Default.getString(Default.SHORT_NAME) + ".exe";
String sparkExe = commandPath + File.separator + Default.getString(Default.SHORT_NAME) + ".exe";
if (!new File(sparkExe).exists()) {
Log.warning("Client EXE file does not exist");
return false;
}
String starterExe = getCommandPath() + File.separator + "starter.exe";
String starterExe = commandPath + File.separator + "starter.exe";
if (!new File(starterExe).exists()) {
Log.warning("Starter EXE file does not exist");
return false;
}
command = starterExe + " \"" + sparkExe + "\"";
command = starterExe + " \"" + sparkExe + "\"";
} else if (Spark.isLinux()) {
command = getCommandPath() + File.separator + Default.getString(Default.SHORT_NAME);
command = commandPath + File.separator + Default.getString(Default.SHORT_NAME);
if (!new File(command).exists()) {
Log.warning("Client startup script does not exist");
return false;

View File

@ -33,38 +33,41 @@ import java.util.Locale;
*/
public class LanguagePlugin implements Plugin {
private Locale[] locales;
private JMenu languageMenu;
@Override
public void initialize() {
// Register with action menu
final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
languageMenu = new JMenu(Res.getString("menuitem.languages"));
String languageMenuLabel = Res.getString("menuitem.languages");
// For non-English locales append "Language" for those who accidentally changed language
if (!Locale.getDefault().getLanguage().equals("en")) {
languageMenuLabel += " (Language)";
}
JMenu languageMenu = new JMenu(languageMenuLabel);
languageMenu.setIcon(SparkRes.getImageIcon("LANGUAGE_ICON"));
locales = Locale.getAvailableLocales();
Locale[] locales = Locale.getAvailableLocales();
// Load files
for (final Locale locale : locales) {
String code = locale.toString();
final String targetI18nFileName;
if (locale.toString().equals("en")) {
if (code.equals("en")) {
targetI18nFileName = "/i18n/spark_i18n.properties";
} else {
targetI18nFileName = "/i18n/spark_i18n_" + locale.toString() + ".properties";
targetI18nFileName = "/i18n/spark_i18n_" + code + ".properties";
}
// If we can find an translation file for this locale, we can support the language!
if (getClass().getResource( targetI18nFileName ) != null) {
addLanguage(locale);
addLanguage(locale, languageMenu);
}
}
actionsMenu.add(languageMenu);
}
private void addLanguage(Locale locale) {
private void addLanguage(Locale locale, JMenu languageMenu) {
Action action = new AbstractAction() {
private static final long serialVersionUID = -7093236616888591766L;
@ -83,10 +86,7 @@ public class LanguagePlugin implements Plugin {
}
}
};
String label = locale.getDisplayLanguage(locale);
if (!locale.getDisplayCountry(locale).isEmpty()) {
label = label + "-" + locale.getDisplayCountry(locale);
}
String label = locale.getDisplayName(locale);
action.putValue(Action.NAME, label);
languageMenu.add(action);
}

View File

@ -621,7 +621,7 @@ message.save.profile = Чтобы сохранить изменения проф
message.search.for.contacts = Найти контакты.
message.search.input.short = Укажите хотя бы две буквы.
message.search.for.other.people = Поиск людей на сервере
message.search.service.not.available = Нет связи с сервисом поиска
message.search.service.not.available = Нет связи с сервисом поиска контактов
message.searching.please.wait = Поиск. Ждите...
message.select.add.room.to.add = Выберете комнату для добавления в Ваш список сервисов
message.select.one.or.more = Выберете одного или нескольких пользователей.