mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IJPL-163439 Synchronize localization settings from the registry at app closing
GitOrigin-RevId: c5d6d60e2081f1b9cc9b55bcdb1990e0b0181680
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d20b69d888
commit
13a6cb55f8
@@ -3,8 +3,13 @@ package com.intellij.ide
|
||||
|
||||
import com.intellij.DynamicBundle
|
||||
import com.intellij.l10n.LocalizationStateService
|
||||
import com.intellij.l10n.LocalizationUtil
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.util.registry.EarlyAccessRegistryManager
|
||||
import com.intellij.util.text.DateTimeFormatManager
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.NoSuchFileException
|
||||
|
||||
private class LanguageBundleListener : AppLifecycleListener {
|
||||
override fun appStarted() {
|
||||
@@ -12,7 +17,37 @@ private class LanguageBundleListener : AppLifecycleListener {
|
||||
(it as PersistentStateComponent<*>).initializeComponent()
|
||||
it.resetLocaleIfNeeded()
|
||||
}
|
||||
EarlyAccessRegistryManager.syncAndFlush()
|
||||
DynamicBundle.clearCache()
|
||||
DateTimeFormatManager.getInstance().resetFormats()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the early access registry file and updates the registry settings related to localization.
|
||||
* This ensures that any changes made externally (e.g., via Toolbox) to the localization settings are accurately reflected.
|
||||
* */
|
||||
override fun appClosing() {
|
||||
val earlyAccessRegistryFile = PathManager.getConfigDir().resolve(EarlyAccessRegistryManager.fileName)
|
||||
val lines = try {
|
||||
Files.lines(earlyAccessRegistryFile)
|
||||
}
|
||||
catch (_: NoSuchFileException) {
|
||||
return
|
||||
}
|
||||
lines.use { lineStream ->
|
||||
val iterator = lineStream.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val key = iterator.next()
|
||||
if (!iterator.hasNext()) {
|
||||
break
|
||||
}
|
||||
val value = iterator.next()
|
||||
if (key == LocalizationUtil.LOCALIZATION_KEY) {
|
||||
EarlyAccessRegistryManager.setString(LocalizationUtil.LOCALIZATION_KEY, value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user