mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
IJPL-159334 use dd-plist library to define macOS region instead of using PListBuddy
GitOrigin-RevId: 270b703106067040e97527f561be322a43352546
This commit is contained in:
committed by
intellij-monorepo-bot
parent
89af9169b4
commit
bf225d5dba
18
.idea/libraries/googlecode_plist_dd.xml
generated
Normal file
18
.idea/libraries/googlecode_plist_dd.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
||||
<component name="libraryTable">
|
||||
<library name="googlecode.plist.dd" type="repository">
|
||||
<properties maven-id="com.googlecode.plist:dd-plist:1.28">
|
||||
<verification>
|
||||
<artifact url="file://$MAVEN_REPOSITORY$/com/googlecode/plist/dd-plist/1.28/dd-plist-1.28.jar">
|
||||
<sha256sum>88ed8e730f7386297485176c4387146c6914a38c0e58fc296e8a01cdc3b621e1</sha256sum>
|
||||
</artifact>
|
||||
</verification>
|
||||
</properties>
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/plist/dd-plist/1.28/dd-plist-1.28.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/plist/dd-plist/1.28/dd-plist-1.28-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -312,6 +312,8 @@ object CommunityLibraryLicenses {
|
||||
LibraryLicense(url = "https://github.com/oshi/oshi", libraryName = "github.oshi.core").mit(
|
||||
"https://github.com/oshi/oshi/blob/master/LICENSE")
|
||||
.suppliedByOrganizations("The OSHI Project Contributors"),
|
||||
LibraryLicense(name = "googlecode.plist.dd", libraryName = "googlecode.plist.dd", url = "https://github.com/3breadt/dd-plist/")
|
||||
.apache("https://github.com/3breadt/dd-plist/blob/master/LICENSE.txt"),
|
||||
LibraryLicense(libraryName = "Gradle", url = "https://gradle.org/", licenseUrl = "https://gradle.org/license")
|
||||
.apache("https://github.com/gradle/gradle/blob/master/LICENSE")
|
||||
.suppliedByOrganizations("Gradle Inc."),
|
||||
|
||||
@@ -142,5 +142,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.core.nio.fs" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ijent.community.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ijent.community.buildConstants" />
|
||||
<orderEntry type="library" name="googlecode.plist.dd" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -16,6 +16,7 @@ import org.xml.sax.SAXException
|
||||
import java.io.IOException
|
||||
import java.io.StringReader
|
||||
|
||||
@Deprecated("Use dd-plist library to work with plist files (https://github.com/3breadt/dd-plist)")
|
||||
@ApiStatus.Internal
|
||||
class PListBuddyWrapper(private val pListPath: String) {
|
||||
private val UTIL_PATH: String = "/usr/libexec/PListBuddy"
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.ui
|
||||
|
||||
import com.dd.plist.NSDictionary
|
||||
import com.dd.plist.PropertyListParser
|
||||
import com.intellij.DynamicBundle
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.LanguageAndRegionBundle
|
||||
import com.intellij.ide.Region
|
||||
import com.intellij.ide.RegionSettings
|
||||
import com.intellij.ide.file.PListBuddyWrapper
|
||||
import com.intellij.ide.gdpr.EndUserAgreement
|
||||
import com.intellij.ide.ui.localization.statistics.EventSource
|
||||
import com.intellij.ide.ui.localization.statistics.LocalizationActionsStatistics
|
||||
@@ -33,6 +34,7 @@ import org.jetbrains.annotations.Nls
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
import java.awt.Graphics
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.swing.*
|
||||
import javax.swing.border.Border
|
||||
@@ -228,10 +230,10 @@ private fun getLocaleFromGeneralPrefMacOs(rootPath: String): Region? {
|
||||
val generalPath = "/Library/Preferences/.GlobalPreferences.plist"
|
||||
val fullPath = rootPath + generalPath
|
||||
try {
|
||||
val readData = PListBuddyWrapper(fullPath).readData("AppleLocale")
|
||||
val elementsByTagName = readData.getElementsByTagName("string")
|
||||
val localeText = elementsByTagName.item(0).textContent
|
||||
val regionText = localeText.substringAfter("@rg=", "")
|
||||
val file = File(fullPath)
|
||||
val rootDict = PropertyListParser.parse(file) as? NSDictionary ?: return null
|
||||
val localeText = rootDict.get("AppleLocale")?.toString() ?: return null
|
||||
val regionText = localeText.toString().substringAfter("@rg=", "")
|
||||
if (regionText.isNotEmpty()) {
|
||||
return regionMapping.keys.find { regionText.startsWith(regionMapping[it]!!, true) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user